From ff7dc48efbeb30f4e93186cd0079d34db5527986 Mon Sep 17 00:00:00 2001 From: DarioS Date: Fri, 20 Aug 2021 20:20:08 +0200 Subject: [PATCH] EgtBEAMWALL 2.3h1 : - modifiche varie per macchine che lavorano sia travi sia pareti (PF1250). --- .../MachGroup Model/MyMachGroupPanelM.vb | 11 + EgtBEAMWALL.Core/SectionXMaterial.vb | 14 +- .../SupervisorMachGroupPanelVM.vb | 22 +- .../MainWindow/MainWindowM.vb | 4 +- .../My Project/AssemblyInfo.vb | 4 +- .../ViewerOptimizerComm.vb | 2 +- .../CALCPanel/CALCPanelVM.vb | 2 +- .../EgtBEAMWALL.ViewerOptimizer.vbproj | 1 - .../Integration/CalcIntegration.vb | 673 --------- .../Integration/Constants.cs | 49 - .../Integration/Generator.cs | 1284 ----------------- .../Integration/Generator.orig.cs | 1276 ---------------- .../Integration/Original.vb | 1211 ---------------- .../MainWindow/MainWindowM.vb | 4 +- .../My Project/AssemblyInfo.vb | 4 +- .../ProdManager/ProdManagerVM.vb | 1 + .../ProjManager/ProjManagerVM.vb | 8 +- 17 files changed, 55 insertions(+), 4515 deletions(-) delete mode 100644 EgtBEAMWALL.ViewerOptimizer/Integration/CalcIntegration.vb delete mode 100644 EgtBEAMWALL.ViewerOptimizer/Integration/Constants.cs delete mode 100644 EgtBEAMWALL.ViewerOptimizer/Integration/Generator.cs delete mode 100644 EgtBEAMWALL.ViewerOptimizer/Integration/Generator.orig.cs delete mode 100644 EgtBEAMWALL.ViewerOptimizer/Integration/Original.vb diff --git a/EgtBEAMWALL.Core/MachGroup Model/MyMachGroupPanelM.vb b/EgtBEAMWALL.Core/MachGroup Model/MyMachGroupPanelM.vb index 5ed4b2cc..a99add57 100644 --- a/EgtBEAMWALL.Core/MachGroup Model/MyMachGroupPanelM.vb +++ b/EgtBEAMWALL.Core/MachGroup Model/MyMachGroupPanelM.vb @@ -51,6 +51,17 @@ Public Class MyMachGroupPanelM TempList.Add(BeamMachGroupM.CreateBeamMachGroup(nId, sName, sMachine)) ElseIf UsedMachine.nType = MachineType.WALL Then TempList.Add(WallMachGroupM.CreateWallMachGroup(nId, sName, sMachine)) + ElseIf UsedMachine.nType = MachineType.BOTH Then + Dim nBTLInfoLayerId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, BTLINFO) + Dim nPROJTYPE As Integer = BWType.NULL + EgtGetInfo(nBTLInfoLayerId, BTL_GEN_PROJTYPE, nPROJTYPE) + If nPROJTYPE = BWType.BEAM Then + TempList.Add(BeamMachGroupM.CreateBeamMachGroup(nId, sName, sMachine)) + ElseIf nPROJTYPE = BWType.WALL Then + TempList.Add(WallMachGroupM.CreateWallMachGroup(nId, sName, sMachine)) + Else + EgtOutLog("Machine of beam & wall type, but project type not found!!") + End If End If nId = EgtGetNextMachGroup(nId) End While diff --git a/EgtBEAMWALL.Core/SectionXMaterial.vb b/EgtBEAMWALL.Core/SectionXMaterial.vb index 4785733e..3c8458b7 100644 --- a/EgtBEAMWALL.Core/SectionXMaterial.vb +++ b/EgtBEAMWALL.Core/SectionXMaterial.vb @@ -5,8 +5,8 @@ Imports EgtWPFLib5 Public Class SectionXMaterial Inherits VMBase - Private Shared m_nType As MachineType - Public Shared Sub SetType(nType As MachineType) + Private Shared m_nType As BWType + Public Shared Sub SetType(nType As BWType) m_nType = nType End Sub @@ -77,9 +77,9 @@ Public Class SectionXMaterial End Property Shared Operator =(ByVal S1 As SectionXMaterial, ByVal S2 As SectionXMaterial) As Boolean - Return (S1.m_dH < S2.m_dH + 100 * EPS_SMALL AndAlso S1.m_dH > S2.m_dH - 100 * EPS_SMALL AndAlso - S1.m_dW < S2.m_dW + 100 * EPS_SMALL AndAlso S1.m_dW > S2.m_dW - 100 * EPS_SMALL AndAlso - S1.m_dL < S2.m_dL + 100 * EPS_SMALL AndAlso S1.m_dL > S2.m_dL - 100 * EPS_SMALL AndAlso + Return (Math.Abs( S1.m_dH - S2.m_dH) < 100 * EPS_SMALL AndAlso + Math.Abs( S1.m_dW - S2.m_dW) < 100 * EPS_SMALL AndAlso + Math.Abs( S1.m_dL - S2.m_dL) < 100 * EPS_SMALL AndAlso S1.m_Material.Any(Function(x) S2.m_Material.Any(Function(y) y = x))) End Operator @@ -95,10 +95,10 @@ Public Class SectionXMaterial End Function Sub New(dW As Double, dH As Double, dL As Double, sMaterial As String) - If m_nType = MachineType.BEAM Then + If m_nType = BWType.BEAM Then m_dW = dW m_dH = dH - ElseIf m_nType = MachineType.WALL Then + ElseIf m_nType = BWType.WALL Then m_dH = dH Else m_dW = dW diff --git a/EgtBEAMWALL.Supervisor/MachGroupPanel/SupervisorMachGroupPanelVM.vb b/EgtBEAMWALL.Supervisor/MachGroupPanel/SupervisorMachGroupPanelVM.vb index fe8c22d3..fc264db4 100644 --- a/EgtBEAMWALL.Supervisor/MachGroupPanel/SupervisorMachGroupPanelVM.vb +++ b/EgtBEAMWALL.Supervisor/MachGroupPanel/SupervisorMachGroupPanelVM.vb @@ -1,6 +1,7 @@ Imports System.Collections.ObjectModel Imports System.ComponentModel Imports System.IO +Imports System.Windows.Threading Imports EgtBEAMWALL.Core Imports EgtUILib Imports EgtWPFLib5 @@ -34,6 +35,9 @@ Public Class SupervisorMachGroupPanelVM ' riferimento su map Map.SetRefSupervisorMachGroupPanelVM(Me) BindingOperations.EnableCollectionSynchronization(m_MachGroupVMList, m_Lock_AddMachGroup) + m_ReloadProj_Timer.Interval = TimeSpan.FromMilliseconds(500) + m_ReloadProj_Timer.Start() + AddHandler m_ReloadProj_Timer.Tick, AddressOf ReloadProject_Tick End Sub #End Region ' CONSTRUCTOR @@ -48,7 +52,16 @@ Public Class SupervisorMachGroupPanelVM MachGroup.NotifyPropertyChanged(NameOf(MachGroup.Produce_IsEnabled)) End Sub + Private m_bReloadProj As Boolean = False + Private m_ReloadProj_Timer As New DispatcherTimer + Public Sub ReloadProjectFile() + m_bReloadProj = True + End Sub + + Public Sub ReloadProject_Tick() + If Not m_bReloadProj Then Return + m_bReloadProj = False Map.refSceneHostVM.MainController.ResetModified() Map.refSceneHostVM.MainController.OpenProject(Map.refSupervisorManagerVM.CurrProd.sProdPath, False) RefreshSupervisorMachGroups(Map.refMachinePanelVM.MachineList.ToList()) @@ -63,7 +76,10 @@ Public Class SupervisorMachGroupPanelVM Dim nId = EgtGetFirstMachGroup() While nId <> GDB_ID.NULL ' se gia' presente, vado al prossimo - If Map.refMachGroupPanelVM.MachGroupVMList.Any(Function(x) x.Id = nId) Then Continue While + If Map.refSupervisorMachGroupPanelVM.MachGroupVMList.Any(Function(x) x.Id = nId) Then + nId = EgtGetNextMachGroup(nId) + Continue While + End If ' altrimenti lo carico EgtSetCurrMachGroup(nId) Dim sName As String = String.Empty @@ -76,9 +92,9 @@ Public Class SupervisorMachGroupPanelVM If Not bOk OrElse UsedMachine.nType = MachineType.NULL Then EgtOutLog("Machine incompatible with beam & wall machining!!") ElseIf UsedMachine.nType = MachineType.BEAM Then - Map.refMachGroupPanelVM.m_MyMachGroupPanelM.AddMachGroup(BeamMachGroupM.CreateBeamMachGroup(nId, sName, sMachine)) + Map.refSupervisorMachGroupPanelVM.m_MyMachGroupPanelM.AddMachGroup(BeamMachGroupM.CreateBeamMachGroup(nId, sName, sMachine)) ElseIf UsedMachine.nType = MachineType.WALL Then - Map.refMachGroupPanelVM.m_MyMachGroupPanelM.AddMachGroup(WallMachGroupM.CreateWallMachGroup(nId, sName, sMachine)) + Map.refSupervisorMachGroupPanelVM.m_MyMachGroupPanelM.AddMachGroup(WallMachGroupM.CreateWallMachGroup(nId, sName, sMachine)) End If nId = EgtGetNextMachGroup(nId) End While diff --git a/EgtBEAMWALL.Supervisor/MainWindow/MainWindowM.vb b/EgtBEAMWALL.Supervisor/MainWindow/MainWindowM.vb index ca2803e2..2c54d380 100644 --- a/EgtBEAMWALL.Supervisor/MainWindow/MainWindowM.vb +++ b/EgtBEAMWALL.Supervisor/MainWindow/MainWindowM.vb @@ -207,8 +207,8 @@ Public Class MainWindowM ' Verifico abilitazione nesting automatico m_bAutoNestOption = Not String.IsNullOrWhiteSpace(sNestKey) ' Recupero livello e opzioni della chiave - Dim bKey As Boolean = EgtGetKeyLevel(5327, 2307, 1, m_nKeyLevel) And - EgtGetKeyOptions(5327, 2307, 1, m_nKeyOptions) + Dim bKey As Boolean = EgtGetKeyLevel(5327, 2308, 1, m_nKeyLevel) And + EgtGetKeyOptions(5327, 2308, 1, m_nKeyOptions) ' Inizializzazione generale di EgtInterface m_nDebug = GetMainPrivateProfileInt(S_GENERAL, K_DEBUG, 0) m_sLogFile = m_sTempDir & "\" & GENLOG_FILE_NAME.Replace("#", m_nInstance.ToString()) diff --git a/EgtBEAMWALL.Supervisor/My Project/AssemblyInfo.vb b/EgtBEAMWALL.Supervisor/My Project/AssemblyInfo.vb index 2207e7aa..e48d9c4d 100644 --- a/EgtBEAMWALL.Supervisor/My Project/AssemblyInfo.vb +++ b/EgtBEAMWALL.Supervisor/My Project/AssemblyInfo.vb @@ -55,5 +55,5 @@ Imports System.Windows ' by using the '*' as shown below: ' - - + + diff --git a/EgtBEAMWALL.Supervisor/ViewerOptimizerCommThread/ViewerOptimizerComm.vb b/EgtBEAMWALL.Supervisor/ViewerOptimizerCommThread/ViewerOptimizerComm.vb index f0204581..15198206 100644 --- a/EgtBEAMWALL.Supervisor/ViewerOptimizerCommThread/ViewerOptimizerComm.vb +++ b/EgtBEAMWALL.Supervisor/ViewerOptimizerCommThread/ViewerOptimizerComm.vb @@ -41,7 +41,7 @@ Public Class ViewerOptimizerComm Map.refProjectVM.SupervisorMachGroupPanelVM.ReloadProjectFile() End If ' lo aggiungo alla lista di MachGroup - Map.refProjectVM.SupervisorMachGroupPanelVM.AddMachGroupToSupervisor(Map.refProjectVM.ProdMachGroupPanelVM.MachGroupVMList.FirstOrDefault(Function(x) x.Id = MachGroupModification.ItemId)) + ' Map.refProjectVM.SupervisorMachGroupPanelVM.AddMachGroupToSupervisor(Map.refProjectVM.ProdMachGroupPanelVM.MachGroupVMList.FirstOrDefault(Function(x) x.Id = MachGroupModification.ItemId)) End Select Next ' se devo ricaricare il file diff --git a/EgtBEAMWALL.ViewerOptimizer/CALCPanel/CALCPanelVM.vb b/EgtBEAMWALL.ViewerOptimizer/CALCPanel/CALCPanelVM.vb index c664b062..52a28c37 100644 --- a/EgtBEAMWALL.ViewerOptimizer/CALCPanel/CALCPanelVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/CALCPanel/CALCPanelVM.vb @@ -529,7 +529,7 @@ Public Class CALCPanelVM If Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) Then Dim TempBarList(0) As EgtBEAMWALL.Core.Bar Dim Bar As New EgtBEAMWALL.Core.Bar With {.nBarId = Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId, - .nProgramPage = ProjectType.PROD, + .nProgramPage = ProjectType.PROJ, .nProjType = ProjType, .bBarOk = True, .nMachineName = Map.refMachinePanelVM.SelectedMachine.Name, diff --git a/EgtBEAMWALL.ViewerOptimizer/EgtBEAMWALL.ViewerOptimizer.vbproj b/EgtBEAMWALL.ViewerOptimizer/EgtBEAMWALL.ViewerOptimizer.vbproj index bc11ee72..f9eb6455 100644 --- a/EgtBEAMWALL.ViewerOptimizer/EgtBEAMWALL.ViewerOptimizer.vbproj +++ b/EgtBEAMWALL.ViewerOptimizer/EgtBEAMWALL.ViewerOptimizer.vbproj @@ -265,7 +265,6 @@ ConfigurationPageV.xaml - MachinePanelV.xaml diff --git a/EgtBEAMWALL.ViewerOptimizer/Integration/CalcIntegration.vb b/EgtBEAMWALL.ViewerOptimizer/Integration/CalcIntegration.vb deleted file mode 100644 index 4140bf47..00000000 --- a/EgtBEAMWALL.ViewerOptimizer/Integration/CalcIntegration.vb +++ /dev/null @@ -1,673 +0,0 @@ -Imports System.IO -Imports System.Threading -Imports System.Globalization -Imports EgtUILib -Imports EgtWPFLib5 -Imports EgtBEAMWALL.Core.ConstBeam -Imports EgtBEAMWALL.Core - -Public Class CalcIntegration - - Private _thread As System.Threading.Thread - - Public Enum CmdType As Integer - GENERATE = 0 - MODIFY = 1 - SIMULATE = 2 - CHECK = 3 - CHECKGEN = 4 - POINT_CLOUD = 5 - RAWPART = 6 - End Enum - - Public Class Bar - 'Public piInfo As PatternInfo - Public nBarState As Integer - Public nBarId As Integer - Public sBarPath As String - Public bBarOk As Boolean - Public nCmdType As Integer - Public nBarType As ProjectType - End Class - - Private Structure MyProc - Public bEnable As Boolean - Public Proc As Process - Public nBar As Integer - End Structure - - Public Sub New() - End Sub - - Delegate Sub CallbackDlg(dProgress As Double, sProgress As String, ByRef bCancel As Boolean) - - Public Sub Run(vBar As Bar(), sProjDirPath As String, callback As CallbackDlg) - _thread = New Thread(Sub() - DoJob(vBar, sProjDirPath, callback) - End Sub) - _thread.Start() - End Sub - - Private Shared Sub DoJob(vBar As Bar(), sProjDirPath As String, callback As CallbackDlg) - Dim bCancel As Boolean = False - callback(0, "Init", bCancel) - - ' creo progetti a seconda del tipo - For Each Bar In vBar - If Bar.nBarType = ProjectType.PROJ Then - Bar.sBarPath = CreateNewProjectFromPart(Bar.nBarId, sProjDirPath) - ElseIf Bar.nBarType = ProjectType.PROD Then - Bar.sBarPath = CreateNewProjectFromMachGroup(Bar.nBarId, sProjDirPath) - End If - Next - - Dim bIsSimulation As Boolean = False - ' se sono in simulazione - If vBar.Count > 0 AndAlso vBar(0).nCmdType = CmdType.SIMULATE Then - bIsSimulation = True - callback(0, "Simulation opened", bCancel) - Else - callback(0.1, "", bCancel) - End If - - Dim ExePath As String = String.Empty - GetMainPrivateProfileString(S_BEAM, K_CALCPATH, "", ExePath) - ' Numero di barre - Dim numBars As Integer = vBar.Count - If numBars = 0 Then Return - - ' Numero di core logici da utilizzare (minimo tra presenti sul PC e imposti da INI) - Dim nMaxThread As Integer = Math.Min(Environment.ProcessorCount, Map.refMainWindowVM.MainWindowM.GetMaxCamInstances()) - - ' Frazione di avanzamento del lavoro (in piu) - Dim dProgress As Double = 0 - 'indice incremento progress durante calcolo barra - Dim nPgsCurrBar As Integer = 0 - Dim nPgsClock As Integer = 0 - - - ' Lancio in parallelo più processi (senza superare il numero di core logici presenti) - Dim vProc As MyProc() = New MyProc(nMaxThread - 1) {} - For j As Integer = 0 To nMaxThread - 1 - vProc(j).nBar = -1 - vProc(j).bEnable = True - Next - - ' Processo i Btl in parallelo - Dim nCurrBar As Integer = 0 - Dim nDoneBar As Integer = 0 - Dim nShiftBar As Integer = 0 - Dim nActProc As Integer = 0 - - While nCurrBar < numBars + nShiftBar OrElse nActProc > 0 - - For j As Integer = 0 To nMaxThread - 1 - If Not vProc(j).bEnable Then Continue For - Dim bDone As Boolean = False - - If vProc(j).nBar = -1 Then - - If nCurrBar < numBars + nShiftBar Then - - If vBar(nCurrBar).bBarOk Then - vProc(j).Proc = New Process() - vProc(j).Proc.StartInfo.FileName = ExePath - vProc(j).Proc.StartInfo.Arguments = """" & vBar(nCurrBar).sBarPath & """ " & - """" & Map.refProjectVM.BTLStructureVM.nPROJTYPE & """ " & - """" & CurrentMachine.sMachineName & """ " & vBar(nCurrBar).nCmdType - vProc(j).Proc.StartInfo.UseShellExecute = False - - If vProc(j).Proc.Start() Then - vProc(j).nBar = nCurrBar - nCurrBar += 1 - nActProc += 1 - End If - Else - If vBar(nCurrBar).nCmdType = CmdType.CHECK OrElse vBar(nCurrBar).nCmdType = CmdType.CHECKGEN Then ProcessResults(vBar(nCurrBar)) - bDone = True - nCurrBar += 1 - End If - End If - Else - - If vProc(j).Proc.HasExited Then - ' se terminato con successo - If vProc(j).Proc.ExitCode = 0 Then - ' salvo il risultato - If vBar(vProc(j).nBar).nCmdType = CmdType.CHECK OrElse vBar(vProc(j).nBar).nCmdType = CmdType.CHECKGEN Then ProcessResults(vBar(vProc(j).nBar)) - bDone = True - vProc(j).nBar = -1 - nActProc -= 1 - ' se superato il numero di processi eseguibili in parallelo - ElseIf vProc(j).Proc.ExitCode = 1 Then - ' aggiungo il pezzo in coda - If numBars + nShiftBar < numBars + nMaxThread Then - vBar(numBars + nShiftBar) = vBar(vProc(j).nBar) - nShiftBar += 1 - End If - ' disabilito il processo - vProc(j).bEnable = False - vProc(j).nBar = -1 - nActProc -= 1 - ' altrimenti (errore generico di esecuzione) - Else - ' salvo il risultato - If vBar(vProc(j).nBar).nCmdType = CmdType.CHECK OrElse vBar(vProc(j).nBar).nCmdType = CmdType.CHECKGEN Then ProcessResults(vBar(vProc(j).nBar)) - bDone = True - vProc(j).nBar = -1 - nActProc -= 1 - End If - Else - vProc(j).Proc.Refresh() - End If - End If - - If bDone Then - ' se non sono in simulazione - If bIsSimulation Then - callback(0, "Simulation closing", bCancel) - Else - ' Dialog con Progress Bar - nDoneBar += 1 - dProgress = 1 / numBars * nDoneBar - Dim sProg As String = (dProgress * 100).ToString("F1", CultureInfo.InvariantCulture) - callback(dProgress, " Progress: " & sProg & "% Count: " & nDoneBar & " / " & numBars, bCancel) - End If - If bCancel Then - ' fine - callback(1, "", bCancel) - ' riabilito interfaccia - Map.refProjectVM.ManageIsEnabled(True) - Map.refMyStatusBarVM.ResetStopProgress() - Return - End If - nPgsCurrBar = 0 - nPgsClock = 0 - Else - ' se non sono in simulazione - If Not bIsSimulation Then - ' aggiorno conteggio - If nPgsClock >= 100 AndAlso nPgsCurrBar < 149 Then - nPgsCurrBar += 1 - dProgress = 1 / numBars * nDoneBar + 1 / numBars / 150 * nPgsCurrBar - Dim sProg As String = (dProgress * 100).ToString("F1", CultureInfo.InvariantCulture) - callback(dProgress, " Progress: " & sProg & "% Count: " & nDoneBar & " / " & numBars, bCancel) - nPgsClock = 0 - End If - End If - End If - nPgsClock += 1 - Thread.Sleep(1) - Next - - ' Verifico che i processi non siano andati tutti in errore - Dim bAllKO As Boolean = True - - For j As Integer = 0 To nMaxThread - 1 - If vProc(j).bEnable Then bAllKO = False - Next - - If bAllKO Then - MessageBox.Show("Execution error (all processes are disabled)") - Exit While - End If - - Thread.Sleep(10) - End While - - Thread.Sleep(300) - - ' se sono in simulazione - If bIsSimulation Then - callback(1, "Simulation closed", bCancel) - Else - callback(1, "Done", bCancel) - End If - ' riabilito interfaccia - Map.refProjectVM.ManageIsEnabled(True) - Map.refMyStatusBarVM.ResetStopProgress() - End Sub - - Private Shared Function CreateNewProjectFromPart(nPartId As Integer, sProjDirPath As String) As String - - ' Aggiorno identificativi per segnalazione errori - UpdateCutIdAndTaskId(nPartId) - - ' Disabilito segnalazione modificato - Dim DisableMgr As New DisableModifiedMgr - - ' Recupero visibilita' pezzo e lo imposto a visibile - Dim nOldPartMode As Integer - EgtGetMode(nPartId, nOldPartMode) - EgtSetMode(nPartId, GDB_MD.STD) - - ' Salvo pezzo nel suo progetto - Dim bOk As Boolean = False - Dim nPDN As Integer = 0 - EgtGetInfo(nPartId, BTL_PRT_PDN, nPDN) - Dim sPartFilePath As String = sProjDirPath & "\" & nPDN.ToString() & ".bwe" - bOk = EgtSaveObjToFile(nPartId, sPartFilePath, NGE.CMPTEXT) - - ' Ripristino visibilita' pezzo - EgtSetMode(nPartId, nOldPartMode) - - ' Ripristino stato segnalazione modifica - DisableMgr.ReEnable() - - Return If(bOk, sPartFilePath, String.Empty) - End Function - - Private Shared Function CreateNewProjectFromMachGroup(nMachGroupId As Integer, sProjDirPath As String) As String - - ' Aggiorno identificativi per segnalazione errori - Dim nOldMachGroup As Integer = EgtGetCurrMachGroup() - If nMachGroupId <> nOldMachGroup Then EgtSetCurrMachGroup(nMachGroupId) - Dim nRawId As Integer = EgtGetFirstRawPart() - While nRawId <> GDB_ID.NULL - If EgtVerifyRawPartPhase(nRawId, 1) Then - Dim nPartId As Integer = EgtGetFirstPartInRawPart(nRawId) - While nPartId <> GDB_ID.NULL - UpdateCutIdAndTaskId(nPartId) - nPartId = EgtGetNextPartInRawPart(nPartId) - End While - End If - nRawId = EgtGetNextRawPart(nRawId) - End While - If nMachGroupId <> nOldMachGroup Then - If nOldMachGroup <> GDB_ID.NULL Then - EgtSetCurrMachGroup(nOldMachGroup) - Else - EgtResetCurrMachGroup() - End If - End If - - ' Salvo gruppo di lavorazione nel suo progetto - Dim sMachGroupName As String = "" - EgtGetMachGroupName(nMachGroupId, sMachGroupName) - Dim sMachGroupFilePath As String = sProjDirPath & "\" & sMachGroupName & ".bwe" - If EgtSaveObjToFile(nMachGroupId, sMachGroupFilePath, NGE.CMPTEXT) Then - Return sMachGroupFilePath - End If - Return String.Empty - End Function - - Private Shared Function UpdateCutIdAndTaskId(nPartId As Integer) As Boolean - ' Assegno Id a CutId per calcoli - EgtSetInfo(nPartId, "CUTID", nPartId, True) - - ' Assegno TASKID agli outline per calcoli - Dim nOutLayerId As Integer = EgtGetFirstNameInGroup(nPartId, OUTLINE) - Dim nOutlineId As Integer = EgtGetFirstInGroup(nOutLayerId) - While nOutlineId <> GDB_ID.NULL - ' verifico che sia una feature - Dim nGRP As Integer - If EgtGetInfo(nOutlineId, BTL_FTR_GRP, nGRP) Then - ' verifico se ha un principale - Dim nMainOffsId As Integer - If EgtGetInfo(nOutlineId, BTL_FTR_MAINID, nMainOffsId) Then - ' assegno TASKID alla feature per calcoli - EgtSetInfo(nOutlineId, "TASKID", nOutlineId + nMainOffsId, True) - Else - ' assegno TASKID alla feature per calcoli - EgtSetInfo(nOutlineId, "TASKID", nOutlineId, True) - End If - End If - nOutlineId = EgtGetNext(nOutlineId) - End While - - ' Assegno TASKID alle feature per calcoli - Dim nProcessingId As Integer = EgtGetFirstNameInGroup(nPartId, PROCESSINGS) - Dim nFeatureId As Integer = EgtGetFirstInGroup(nProcessingId) - While nFeatureId <> GDB_ID.NULL - ' verifico che sia una feature - Dim nGRP As Integer - If EgtGetInfo(nFeatureId, BTL_FTR_GRP, nGRP) Then - ' verifico se ha un principale - Dim nMainOffsId As Integer - If EgtGetInfo(nFeatureId, BTL_FTR_MAINID, nMainOffsId) Then - ' assegno TASKID alla feature per calcoli - EgtSetInfo(nFeatureId, "TASKID", nFeatureId + nMainOffsId, True) - Else - ' assegno TASKID alla feature per calcoli - EgtSetInfo(nFeatureId, "TASKID", nFeatureId, True) - End If - End If - nFeatureId = EgtGetNext(nFeatureId) - End While - Return True - End Function - - Private Shared Sub ProcessResults(Bar As Bar) - - Dim BtlPath As String = Bar.sBarPath - Dim ResPath As String = Path.ChangeExtension(BtlPath, ".txt") - Dim bErrors As Boolean = False - Dim nLastErr As Integer = 0 - Dim sLastMsg As String = "" - Dim nCurrCutId As Integer = 0 - Dim nTotTime As Integer = 0 - - If File.Exists(ResPath) Then - - Dim ProcessResultList As New List(Of ProcessResult) - Dim nErr As Integer = 0 - Dim sMsg As String = "" - Dim dRot As Double = 0 - Dim nFall As Integer = 0 - Dim dPartRot As Double = 0 - Dim dTotRot As Double = 0 - Dim cutId As Integer = 0 - Dim taskId As Integer = 0 - Dim prevCutId As Integer = GDB_ID.NULL - Dim currBTLPart As BTLPartVM = Nothing - Dim currPart As PartVM - - Dim lines As String() = System.IO.File.ReadAllLines(ResPath) - For Each line As String In lines - - If line.StartsWith("ERR=") Then - Dim nVal As Integer? = GetVal(line, "ERR") - nErr = (If(nVal IsNot Nothing, nVal.Value, 0)) - sMsg = "" - dRot = 0 - nFall = 0 - cutId = 0 - taskId = 0 - ElseIf line.StartsWith("ROT=") Then - Dim nVal As Integer? = GetVal(line, "ROT") - Dim nRot As Integer = (If(nVal IsNot Nothing, nVal.Value, 0)) - dRot = Math.Abs(((4 - nRot) Mod 4) * 90) - dPartRot = Math.Max(dPartRot, dRot) - dTotRot = Math.Max(dTotRot, dRot) - ElseIf line.StartsWith("CUTID=") Then - Dim nVal As Integer? = GetVal(line, "CUTID") - cutId = If(nVal IsNot Nothing, nVal.Value, 0) - ElseIf line.StartsWith("TASKID=") Then - Dim nVal As Integer? = GetVal(line, "TASKID") - taskId = (If(nVal IsNot Nothing, nVal.Value, 0)) - ProcessResultAdd(ProcessResultList, ProcessResult.CreateTaskResult(cutId, taskId, nErr, sMsg, dRot), Bar) - ElseIf line.StartsWith("FALL=") Then - Dim nVal As Integer? = GetVal(line, "FALL") - nFall = (If(nVal IsNot Nothing, nVal.Value, 0)) - ProcessResultList.Add(ProcessResult.CreateFallResult(cutId, nErr, sMsg, nFall)) - ElseIf line.StartsWith("TIME=") Then - Dim nVal As Integer? = GetVal(line, "TIME") - nTotTime = (If(nVal IsNot Nothing, nVal.Value, 0)) - ProcessResultList.Add(ProcessResult.CreateTimeResult(cutId, nTotTime)) - 'If Bar.nBarType = ProjectType.PROJ AndAlso Not IsNothing(currBTLPart) Then - ' EgtSetInfo(currBTLPart.nPartId, If(Bar.nBarType = ProjectType.PROJ, ITG_PROJ_TIME, ITG_PROD_TIME), nTotTime, True) - 'End If - ElseIf Not String.IsNullOrWhiteSpace(line) AndAlso line <> "---" Then - sMsg = line - End If - Next - - If ProcessResultList.Count > 0 Then - If Bar.nBarType = ProjectType.PROJ Then - ' Inizializzo il pezzo in verifica - Dim BTLPart As BTLPartVM = GetBTLPartVMFromPartId(Bar.nBarId) - BTLPart.CalcPartUpdate(0, 0, "") - Else - ' Inizializzo i pezzi del gruppo di lavoro in verifica - Dim Machgroup As MyMachGroupVM = GetMachgroupVMFromMachgroupId(Bar.nBarId) - For Each Part In Machgroup.PartVMList - Part.CalcPartUpdate(0, 0, "") - Next - Machgroup.CalcMachGroupUpdate(0, 0, "") - End If - ' Ciclo ... - Dim nCUTID As Integer = -1 - Dim CurrBTLPartVM As BTLPartVM - Dim CurrPartVM As PartVM - Dim CurrMachgroupVM As MyMachGroupVM - Dim CurrBTLFeatureVM As BTLFeatureVM - For Each Line In ProcessResultList - ' se necessario recupero part - If Line.nCUTID <> 0 Then - If Line.nCUTID <> nCUTID Then - nCUTID = Line.nCUTID - If Bar.nBarType = ProjectType.PROJ Then - ' aggiorno nuovo pezzo - CurrBTLPartVM = GetBTLPartVMFromPartId(Line.nCUTID) - Else - ' aggiorno nuovo pezzo - CurrPartVM = GetPartVMFromPartId(Line.nCUTID) - End If - End If - Else - ' se CutId = 0 - If Bar.nBarType = ProjectType.PROJ Then - ' imposto unico pezzo presente - CurrBTLPartVM = GetBTLPartVMFromPartId(Bar.nBarId) - Else - ' riporto errore barra - CurrMachgroupVM = GetMachgroupVMFromMachgroupId(Bar.nBarId) - End If - End If - ' se necessario recupero feature - If Line.nTASKID <> 0 Then - If Bar.nBarType = ProjectType.PROJ Then - CurrBTLFeatureVM = GetBTLFeatureVMFromBTLPartId(CurrBTLPartVM, Line.nTASKID) - Else - CurrBTLFeatureVM = GetFeatureVMFromPartId(CurrPartVM, Line.nTASKID) - End If - Else - CurrBTLFeatureVM = Nothing - End If - Select Case Line.Type - Case ProcessResult.ProcessResultTypes.BAR - If Bar.nBarType = ProjectType.PROJ Then - CurrBTLPartVM.CalcPartUpdate(Line.nERR, Line.dROT, Line.sMSG) - Else - CurrMachgroupVM.CalcMachGroupUpdate(Line.nERR, Line.dROT, Line.sMSG) - End If - Case ProcessResult.ProcessResultTypes.PART - If Bar.nBarType = ProjectType.PROJ Then - CurrBTLPartVM.CalcPartUpdate(Line.nERR, Line.dROT, Line.sMSG) - Else - CurrPartVM.CalcPartUpdate(Line.nERR, Line.dROT, Line.sMSG) - End If - Case ProcessResult.ProcessResultTypes.TASKID - CurrBTLFeatureVM.CalcFeatureUpdate(Line.nERR, Line.dROT, Line.sMSG) - Case ProcessResult.ProcessResultTypes.FALL - If Bar.nBarType = ProjectType.PROJ Then - CurrBTLPartVM.CalcFallUpdate(Line.nFALL) - Else - CurrPartVM.CalcFallUpdate(Line.nFALL) - End If - Case ProcessResult.ProcessResultTypes.TIME - If Bar.nBarType = ProjectType.PROJ Then - CurrBTLPartVM.CalcTimeUpdate(Line.nTIME) - Else - If IsNothing(CurrMachgroupVM) Then CurrMachgroupVM = GetMachgroupVMFromMachgroupId(Bar.nBarId) - CurrMachgroupVM.CalcTimeUpdate(Line.nTIME) - End If - End Select - Next - If Bar.nBarType = ProjectType.PROJ Then - ' aggiorno il pezzo - Dim BTLPart As BTLPartVM = GetBTLPartVMFromPartId(Bar.nBarId) - BTLPart.CalcGlobalUpdate() - ' lancio aggiornamento tempo su BTL - Map.refProjectVM.BTLStructureVM.CalcGlobalTime() - Else - Dim Machgroup As MyMachGroupVM = GetMachgroupVMFromMachgroupId(Bar.nBarId) - For Each Part In Machgroup.PartVMList - Part.CalcGlobalUpdate() - Next - Machgroup.CalcGlobalUpdate() - ' lancio aggiornamento tempo su MachgroupPanel - Map.refProjectVM.MachGroupPanelVM.CalcGlobalTime() - End If - - End If - - Else - bErrors = True - nLastErr = 25 - sLastMsg = "Execution Error" - End If - - End Sub - - Private Shared Function GetVal(sText As String, sKey As String) As Integer? - Dim sParts As String() = sText.Split("="c) - If String.Compare(sParts(0), sKey) <> 0 Then Return Nothing - Dim nVal As Integer = Nothing - - If Not Integer.TryParse(sParts(1), nVal) Then - Return Nothing - Else - Return nVal - End If - End Function - - Private Shared Sub ProcessResultAdd(PRList As List(Of ProcessResult), NewPR As ProcessResult, Bar As Bar) - Dim Prev As ProcessResult - Select Case NewPR.Type - Case ProcessResult.ProcessResultTypes.BAR - If Bar.nBarType = ProjectType.PROJ Then - Prev = PRList.FirstOrDefault(Function(x) x.Type = ProcessResult.ProcessResultTypes.PART) - Else - Prev = PRList.FirstOrDefault(Function(x) x.Type = ProcessResult.ProcessResultTypes.BAR) - End If - Case ProcessResult.ProcessResultTypes.PART - Prev = PRList.FirstOrDefault(Function(x) x.Type = ProcessResult.ProcessResultTypes.PART AndAlso x.nCUTID = NewPR.nCUTID) - Case ProcessResult.ProcessResultTypes.TASKID - Prev = PRList.FirstOrDefault(Function(x) x.Type = ProcessResult.ProcessResultTypes.TASKID AndAlso x.nCUTID = NewPR.nCUTID AndAlso x.nTASKID = NewPR.nTASKID) - End Select - If IsNothing(Prev) Then - PRList.Add(NewPR) - ElseIf NewPR.nERR = 22 Or (NewPR.nERR > 0 And Prev.nERR <= 0) Or (NewPR.nERR < 0 And Prev.nERR = 0) Then - If NewPR.dROT = 0 And Prev.dROT <> NewPR.dROT Then - NewPR.SetROT(Prev.dROT) - End If - PRList.Remove(Prev) - PRList.Add(NewPR) - ElseIf Prev.dROT = 0 And Prev.dROT <> NewPR.dROT Then - Prev.SetROT(NewPR.dROT) - End If - End Sub - - Private Shared Function GetBTLPartVMFromPartId(nPartId As Integer) As BTLPartVM - Return Map.refProjectVM.BTLStructureVM.BTLPartVMList.FirstOrDefault(Function(x) x.nPartId = nPartId) - End Function - - Private Shared Function GetPartVMFromPartId(nPartId As Integer) As PartVM - For Each MachGroupVM As MyMachGroupVM In Map.refProjectVM.MachGroupPanelVM.MachGroupVMList - Dim PartVM As PartVM = MachGroupVM.PartVMList.FirstOrDefault(Function(x) x.nPartId = nPartId) - If Not IsNothing(PartVM) Then Return PartVM - Next - End Function - - Private Shared Function GetMachgroupVMFromMachgroupId(nMachGroupId As Integer) As MyMachGroupVM - Return Map.refProjectVM.MachGroupPanelVM.MachGroupVMList.FirstOrDefault(Function(x) x.Id = nMachGroupId) - End Function - - Private Shared Function GetBTLFeatureVMFromBTLPartId(BTLPartVM As BTLPartVM, nFeatureId As Integer) As Core.BTLFeatureVM - Return BTLPartVM.BTLFeatureVMList.FirstOrDefault(Function(x) x.nFeatureId = nFeatureId) - End Function - - Private Shared Function GetFeatureVMFromPartId(PartVM As PartVM, nFeatureId As Integer) As Core.BTLFeatureVM - Return PartVM.FeatureVMList.FirstOrDefault(Function(x) x.nFeatureId = nFeatureId) - End Function - -End Class - -Public Class ProcessResult - - Public Enum ProcessResultTypes As Integer - BAR = 1 - PART = 2 - TASKID = 3 - FALL = 4 - TIME = 5 - End Enum - - Private m_Type As ProcessResultTypes - Public ReadOnly Property Type As ProcessResultTypes - Get - Return m_Type - End Get - End Property - - Private m_nCUTID As Integer - Public ReadOnly Property nCUTID As Integer - Get - Return m_nCUTID - End Get - End Property - - Private m_nTASKID As Integer - Public ReadOnly Property nTASKID As Integer - Get - Return m_nTASKID - End Get - End Property - - Private m_nERR As Integer - Public ReadOnly Property nERR As Integer - Get - Return m_nERR - End Get - End Property - - Private m_sMSG As String - Public ReadOnly Property sMSG As String - Get - Return m_sMSG - End Get - End Property - - Private m_dROT As Double - Public ReadOnly Property dROT As Double - Get - Return m_dROT - End Get - End Property - Friend Sub SetROT(value As Double) - m_dROT = value - End Sub - - Private m_nFALL As Integer - Public ReadOnly Property nFALL As Integer - Get - Return m_nFALL - End Get - End Property - - Private m_nTIME As Integer - Public ReadOnly Property nTIME As Integer - Get - Return m_nTIME - End Get - End Property - - Public Shared Function CreateTaskResult(CUTID As Integer, TASKID As Integer, ERR As Integer, MSG As String, ROT As Double) As ProcessResult - If CUTID <> 0 Then - If TASKID = 0 Then - Return New ProcessResult(ProcessResultTypes.PART, CUTID, TASKID, ERR, MSG, ROT, 0, 0) - End If - Return New ProcessResult(ProcessResultTypes.TASKID, CUTID, TASKID, ERR, MSG, ROT, 0, 0) - End If - Return New ProcessResult(ProcessResultTypes.BAR, CUTID, TASKID, ERR, MSG, ROT, 0, 0) - End Function - Public Shared Function CreateFallResult(CUTID As Integer, ERR As Integer, MSG As String, FALL As Integer) As ProcessResult - Return New ProcessResult(ProcessResultTypes.FALL, CUTID, 0, ERR, MSG, 0, FALL, 0) - End Function - Public Shared Function CreateTimeResult(CUTID As Integer, TIME As Integer) As ProcessResult - Return New ProcessResult(ProcessResultTypes.TIME, CUTID, 0, 0, "", 0, 0, TIME) - End Function - - Protected Sub New(Type As ProcessResultTypes, CUTID As Integer, TASKID As Integer, ERR As Integer, MSG As String, ROT As Double, FALL As Integer, TIME As Integer) - m_Type = Type - m_nCUTID = CUTID - m_nTASKID = TASKID - m_nERR = ERR - m_sMSG = MSG - m_dROT = ROT - m_nFALL = FALL - m_nTIME = TIME - End Sub - -End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/Integration/Constants.cs b/EgtBEAMWALL.ViewerOptimizer/Integration/Constants.cs deleted file mode 100644 index b0caff72..00000000 --- a/EgtBEAMWALL.ViewerOptimizer/Integration/Constants.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -class Constants -{ - // Le seguenti costanti stringa sono parti di testo del file BTL di output - public const string VERSION = "VERSION: BTL V10.6" ; - public const string BUILD = "BUILD: \"10600\"" ; - public const string GENERAL = "[GENERAL]" ; - public const string PART = "[PART]" ; - public const string PROJECT_NUMBER = "PROJECTNUMBER: " ; - public const string SCALE_UNIT = "SCALEUNIT: " ; - public const string SINGLE_MEMBER_NUMBER = "SINGLEMEMBERNUMBER: " ; - public const string DESIGNATION = "DESIGNATION: " ; - public const string COUNT = "COUNT: " ; - public const string LENGTH = "LENGTH: " ; - public const string HEIGHT = "HEIGHT: " ; - public const string WIDTH = "WIDTH: " ; - public const string OUTLINE_KEY = "OUTLINE: "; - public const string APERTURE_KEY = "APERTURE: "; - public const string SIDE = "SIDE: "; - public const string PROCESS_KEY = "PROCESSKEY: "; - public const string PROCESS_PARAMETERS = "PROCESSPARAMETERS: " ; - public const string REFERENCE_PLANE = "REFERENCEPLANE: " ; - public const string PROCESS_IDENT = "PROCESSIDENT: " ; - public const string PROCESS = "PROCESS: " ; - public const string COMMENT = "COMMENT: " ; - public const string USERATTRIBUTE = "USERATTRIBUTE: " ; - public const string EIGHT_ZEROS = "00000000" ; - - // Numero di cifre decimali dei valori dei parametri BTL - public const int scaleUnit = 2 ; - - // Allungamento della barra per pezzi singoli da Vista - public const double BarMaxLenForAdd = 2000 ; - public const double BarAddLen = 2000 ; - - // Sovramateriale di testa per travi singole di Vista - public const double HeadOverMat = 10 ; - - // Sovramateriale per pareti singole di Vista - public const double PanelOverMat = 10 ; - - // Id base per punti di contorni liberi - public const int FcBaseId = 10000 ; -} \ No newline at end of file diff --git a/EgtBEAMWALL.ViewerOptimizer/Integration/Generator.cs b/EgtBEAMWALL.ViewerOptimizer/Integration/Generator.cs deleted file mode 100644 index 3d9124d6..00000000 --- a/EgtBEAMWALL.ViewerOptimizer/Integration/Generator.cs +++ /dev/null @@ -1,1284 +0,0 @@ -using System; -using System.Windows.Forms; -using System.Collections.Generic; -using System.Data; -using System.Data.SqlClient; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using System.Globalization ; -using ib.essetre.integration; -using ib.essetre.integration.egaltech; - -public class Generator : ib.essetre.integration.IGenerator -{ - private System.Threading.Thread _thread ; - private static DataSet _ds = new DataSet() ; - private static string _SqlConnectionStr = "" ; - - private struct Bar - { - public PatternInfo piInfo ; - public int nBarState ; - public string sBtlPath ; - public bool bBtlOk ; - } - - private struct MyProc - { - public bool bEnable ; - public Process Proc ; - public int nBar ; - } - - //------------------------------------------------------------------------------------------------------------- - public Generator() - { - } - - //------------------------------------------------------------------------------------------------------------- - public void Run(InOutParameters parameters, ICallBack callback) - { - _thread = new Thread(() => DoJob( parameters, callback)) ; - _thread.Start() ; - } - - private delegate void dDoJob( InOutParameters parameters, ICallBack callback) ; - - // Proj - // Creo progetto barra da pezzo - private static void CreateRawPartProjectFromPart(integer nPartId) - { - EgtNew - } - - //------------------------------------------------------------------------------------------------------------- - // campo data ultima modifica nel DATABASE [lastModified] - private static void DoJob( InOutParameters parameters, ICallBack callback) - { - bool bCancel = false ; - callback.Progress( 0, "Init", ref bCancel) ; - - // creo progetti per ogni barra - - - - _SqlConnectionStr = parameters.ConnectionString ; - - String ExePath = GetExePath( parameters) ; - String DataDir = GetDataDir( parameters) ; - - // Numero di barre - int numBars = parameters.Patterns.Length ; - if ( numBars == 0) - return ; - - // Se modalità Cloud, allora conta solo la prima barra - bool bCloud = ( parameters.UIMode == InOutParameters.UIModes.CLOUD) ; - if ( bCloud) - numBars = 1 ; - - // Numero di core logici da utilizzare (minimo tra presenti sul PC e imposti da INI) - int nMaxThread = Math.Min( Environment.ProcessorCount, GetMaxInstances( parameters)) ; - - // Frazione di avanzamento del lavoro (in pu) - double dProgress = 0 ; - - // Genero i Btl di tutte le barre - Bar[] vBar = new Bar[ numBars + nMaxThread] ; - for ( int i = 0; i < numBars; i++) { - - PatternInfo pattInfo = parameters.Patterns[i] ; - - BTL btlObject = new BTL() ; - - // Se il parametro IsFromProject è TRUE viene eseguita la query sulle tabelle Project, - // se invece è FALSE viene eseguita la query sulle tabelle Production - string sql = "" ; - if ( pattInfo.IsFromProject) { - sql = "SELECT E.projectId, " + - "E.elementId, 0 cutId, processId, info1, info2, enabled, level, " + - "inTools, outTools, isChecked, P.done, isoType, ax, ay, az, P.x, P.y, P.z, " + - "P.flagDeleted, P.[group], [key], face, edge, des, " + - "p01, p02, p03, p04, p05, p06, p07, p08, p09, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, " + - "q01, q02, q03, q04, q05, q06, q07, q08, q09, q10, q11, q12, q13, q14, q15, q16, q17, q18, q19, q20, " + - "ox, oy, oz, xx, xy, xz, yx, yy, yz, " + - "priority, processIdent, processingQuality, sag1, text, E.projectId, E.elementId, P.processId, 0 cutStart, 0 cutEnd, " + - "E.inverted, E.rotated, 0 doneTime, 0 startAngle, 0 endAngle, -1 referenceCutId, E.length, E.width, E.height " + - "FROM dbo.vw_Process AS P " + - "RIGHT OUTER JOIN dbo.vw_Element AS E " + - "ON P.projectId=E.projectId AND P.elementId=E.elementId " + - "WHERE E.projectId = @firstId AND E.elementId = @secondId" ; - } - else { - sql = "SELECT vw_Cut.productionId, " + - "vw_Cut.patternId, vw_Cut.cutId, taskId, info1, info2, enabled, level, " + - "inTools, outTools, isChecked, vw_Task.done, isoType, ax, ay, az, vw_Cut.x, vw_Cut.y, vw_Cut.z, " + - "vw_Task.flagDeleted, [group], [key], face, edge, des, " + - "p01, p02, p03, p04, p05, p06, p07, p08, p09, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, " + - "q01, q02, q03, q04, q05, q06, q07, q08, q09, q10, q11, q12, q13, q14, q15, q16, q17, q18, q19, q20, " + - "ox, oy, oz, xx, xy, xz, yx, yy, yz, " + - "priority, processIdent, processingQuality, sag1, text, vw_Cut.projectId, vw_Cut.elementId, cutStart, cutEnd, " + - "inverted, rotated, doneTime, startAngle, endAngle, referenceCutId, length, width, height " + - "FROM dbo.vw_Task " + - "RIGHT OUTER JOIN dbo.vw_Cut " + - "ON (vw_Task.cutId = vw_Cut.cutId AND vw_Task.patternId = vw_Cut.patternId AND vw_Task.productionId = vw_Cut.productionId) " + - "WHERE vw_Cut.productionId = @firstId AND vw_Cut.patternId = @secondId" ; - } - - // Connessione al DB ed esecuzione query - using ( SqlConnection cn = new SqlConnection( _SqlConnectionStr)) { - cn.Open() ; - using (SqlCommand cmd = new SqlCommand( sql, cn)) { - cmd.Parameters.Add( "@firstId", SqlDbType.Int) ; - cmd.Parameters.Add( "@secondId", SqlDbType.Int) ; - if ( pattInfo.IsFromProject) { - cmd.Parameters["@firstId"].Value = pattInfo.ProjectId ; - cmd.Parameters["@secondId"].Value = pattInfo.ElementId ; - } - else { - cmd.Parameters["@firstId"].Value = pattInfo.ProductionId ; - cmd.Parameters["@secondId"].Value = pattInfo.PatternId ; - } - var dataAdapter = new SqlDataAdapter( cmd) ; - - // Lettura DB e riempimento DataSet - _ds.Clear() ; - dataAdapter.Fill( _ds) ; - } - } - - // Verifica parametro isFromProject: nel caso Ordine viene ottenuta la lista dei Process, - // nel caso Produzione viene ottenuta la lista dei Task - if ( pattInfo.IsFromProject) - GetListaProcesses( btlObject) ; - else - GetListaTasks( btlObject) ; - - // Recupero lo stato della barra - int nBarState = 0 ; - if ( ! pattInfo.IsFromProject) - nBarState = GetBarStateP( btlObject.patternId, btlObject.productionId) ; - - // Dialog con Progress Bar - dProgress += 0.1 / numBars ; - string sProg = ( dProgress * 100).ToString("F1", CultureInfo.InvariantCulture) ; - callback.Progress( (float) dProgress, - " Progress: " + sProg + "%" + "\n", - ref bCancel) ; - if ( bCancel) { - callback.Done( parameters) ; //fine - return ; - } - - // Scrittura del file BTL - // Path completa del nome del file da salvare - string BtlPath = GetBtlPath( DataDir, pattInfo) ; - bool BtlOk = btlObject.WriteIntoFile( BtlPath, pattInfo.IsFromProject) ; - - // Se modalità cloud, scrittura del file di punti - bool bErrOnCloud = false ; - if ( bCloud) { - if ( pattInfo.Cloud != null) { - using ( var tw = new StreamWriter( Path.ChangeExtension( BtlPath, ".pnt"), false)) { - for ( int j = 0 ; j < pattInfo.Cloud.Count() ; j++) { - double dPosX = - pattInfo.Cloud[j].Y ; - double dPosY = pattInfo.Cloud[j].X ; - string sPosX = dPosX.ToString( "0.00", System.Globalization.CultureInfo.InvariantCulture) ; - string sPosY = dPosY.ToString( "0.00", System.Globalization.CultureInfo.InvariantCulture) ; - tw.WriteLine( sPosX + " " + sPosY) ; - } - } - } - else { - BtlOk = false ; - bErrOnCloud = true ; - } - } - - // Se scrittura Btl non riuscita - if ( ! BtlOk) { - // scrivo direttamente il file di errore - int ErrCutId = ( pattInfo.IsFromProject ? pattInfo.ElementId : pattInfo.PatternId) ; - using ( var tw = new StreamWriter( Path.ChangeExtension( BtlPath, ".txt"), false)) { - tw.WriteLine( "ERR=10") ; - tw.WriteLine( bErrOnCloud ? "Cloud without points" : "BTL without processes") ; - tw.WriteLine( "CUTID=" + ErrCutId.ToString()) ; - tw.WriteLine( "TASKID=0") ; - } - // elimino eventuale file Cn già presente - if ( parameters.UIMode == InOutParameters.UIModes.HIDDEN) { - string CncPath = Path.ChangeExtension( BtlPath, ".cnc") ; - if ( File.Exists( CncPath)) - File.Delete( CncPath) ; - } - } - // altrimenti - else { - // cancello eventuale file di errore già presente - string TxtPath = Path.ChangeExtension( BtlPath, ".txt") ; - if ( File.Exists( TxtPath)) - File.Delete( TxtPath) ; - } - - // Salvo dati - vBar[i].piInfo = pattInfo ; - vBar[i].nBarState = nBarState ; - vBar[i].sBtlPath = BtlPath ; - vBar[i].bBtlOk = BtlOk ; - } - - // Lancio in parallelo più processi (senza superare il numero di core logici presenti) - MyProc[] vProc = new MyProc[nMaxThread] ; - for ( int j = 0 ; j < nMaxThread ; ++ j) { - vProc[j].nBar = -1 ; - vProc[j].bEnable = true ; - } - - // Processo i Btl in parallelo - int nCurrBar = 0 ; - int nDoneBar = 0 ; - int nShiftBar = 0 ; - int nActProc = 0 ; - while ( nCurrBar < numBars + nShiftBar || nActProc > 0) { - for ( int j = 0 ; j < nMaxThread ; ++ j) { - if ( ! vProc[j].bEnable) - continue ; - bool bDone = false ; - if ( vProc[j].nBar == -1) { - if ( nCurrBar < numBars + nShiftBar) { - if ( vBar[nCurrBar].bBtlOk) { - vProc[j].Proc = new Process() ; - vProc[j].Proc.StartInfo.FileName = ExePath ; - int nMode = (int)parameters.UIMode ; - if ( parameters.UIMode == InOutParameters.UIModes.HIDDEN && vBar[nCurrBar].nBarState != 0) - nMode = 4 ; - vProc[j].Proc.StartInfo.Arguments = "\"" + vBar[nCurrBar].sBtlPath + "\" " + parameters.MachineName + " " + nMode.ToString() ; - vProc[j].Proc.StartInfo.UseShellExecute = false ; - if ( vProc[j].Proc.Start()) { - vProc[j].nBar = nCurrBar ; - nCurrBar ++ ; - nActProc ++ ; - } - } - else { - ProcessResults( vBar[nCurrBar].sBtlPath, vBar[nCurrBar].piInfo, parameters.UIMode) ; - bDone = true ; - nCurrBar ++ ; - } - } - } - else { - if ( vProc[j].Proc.HasExited) { - // se terminato con successo - if ( vProc[j].Proc.ExitCode == 0) { - // salvo il risultato - ProcessResults( vBar[vProc[j].nBar].sBtlPath, vBar[vProc[j].nBar].piInfo, parameters.UIMode) ; - bDone = true ; - vProc[j].nBar = -1 ; - nActProc -- ; - } - // se superato il numero di processi eseguibili in parallelo - else if ( vProc[j].Proc.ExitCode == 1) { - // aggiungo il pezzo in coda - if ( numBars + nShiftBar < numBars + nMaxThread) { - vBar[numBars + nShiftBar] = vBar[vProc[j].nBar] ; - nShiftBar ++ ; - } - // disabilito il processo - vProc[j].bEnable = false ; - vProc[j].nBar = -1 ; - nActProc -- ; - } - // altrimenti (errore generico di esecuzione) - else { - // salvo il risultato - ProcessResults( vBar[vProc[j].nBar].sBtlPath, vBar[vProc[j].nBar].piInfo, parameters.UIMode) ; - bDone = true ; - vProc[j].nBar = -1 ; - nActProc -- ; - } - } - else - vProc[j].Proc.Refresh() ; - } - if ( bDone) { - // Dialog con Progress Bar - dProgress += ( 0.9 / numBars) ; - nDoneBar ++ ; - string sProg = ( dProgress * 100 ).ToString("F1", CultureInfo.InvariantCulture) ; - callback.Progress((float)dProgress, - " Progress: " + sProg + "%" + "\n" + - " Count: " + nDoneBar + " / " + numBars, - ref bCancel); - if ( bCancel ) { - callback.Done( parameters) ; // fine - return ; - } - } - Thread.Sleep( 1) ; - } - // Verifico che i processi non siano andati tutti in errore - bool bAllKO = true ; - for ( int j = 0 ; j < nMaxThread ; ++ j) { - if ( vProc[j].bEnable) - bAllKO = false ; - } - if ( bAllKO) { - MessageBox.Show( "Execution error (all processes are disabled)") ; - break ; - } - Thread.Sleep( 10) ; - } - - callback.Progress( 1, "End", ref bCancel) ; - Thread.Sleep( 300) ; - - callback.Done( parameters) ; // fine - } - - //------------------------------------------------------------------------------------------------------------- - public void Abort() - { - //non implementata al momento - } - - //------------------------------------------------------------------------------------------------------------- - private static void ProcessResults( string BtlPath, PatternInfo pattInfo, InOutParameters.UIModes UIMode) - { - if ( UIMode == InOutParameters.UIModes.SHOWUI || UIMode == InOutParameters.UIModes.SIMULAZIONE) - return ; - bool bErrors = false ; - int nLastErr = 0 ; - string sLastMsg = "" ; - int nCurrCutId = 0 ; - Dictionary dctErr = new Dictionary() ; - Dictionary dctRot = new Dictionary() ; - int nTotTime = 0 ; - if ( File.Exists( Path.ChangeExtension( BtlPath, ".txt"))) { - int nErr = 0 ; - string sMsg = "" ; - double dRot = 0 ; - int cutId = 0 ; - int taskId = 0 ; - string[] lines = System.IO.File.ReadAllLines( Path.ChangeExtension( BtlPath, ".txt")) ; - foreach ( string line in lines) { - if ( line.StartsWith( "ERR=")) { - int? nVal = GetVal(line, "ERR") ; - nErr = ( nVal != null ? nVal.Value : 0) ; - sMsg = "" ; - cutId = 0 ; - taskId = 0 ; - } - else if ( line.StartsWith( "ROT=")) { - int? nVal = GetVal( line, "ROT") ; - int nRot = ( nVal != null ? nVal.Value : 0) ; - dRot = (( 4 - nRot) % 4) * 90 ; - } - else if ( line.StartsWith( "CUTID=")) { - int? nVal = GetVal( line, "CUTID") ; - cutId = ( nVal != null ? nVal.Value : 0) ; - if ( cutId != nCurrCutId) { - nCurrCutId = cutId ; - dctErr.Clear() ; - dctRot.Clear() ; - } - } - else if ( line.StartsWith( "TASKID=")) { - int? nVal = GetVal( line, "TASKID") ; - taskId = ( nVal != null ? nVal.Value : 0) ; - PatternInfo.Results resExe = PatternInfo.Results.OK ; - if ( nErr == 22) { - resExe = PatternInfo.Results.COLLISION ; - bErrors = true ; - // se non assegnata a feature la dichiaro globale - if ( cutId == 0 || taskId == 0) { - nLastErr = nErr ; - sLastMsg = sMsg ; - } - } - else if ( nErr > 0) { - resExe = PatternInfo.Results.WARNING ; - bErrors = true ; - // se non assegnata a feature la dichiaro globale - if ( cutId == 0 || taskId == 0) { - nLastErr = nErr ; - sLastMsg = sMsg ; - } - } - // gestione errore per feature identificata - if ( taskId != 0) { - // verifiche per feature con più parti - if ( dctErr.TryGetValue( taskId, out PatternInfo.Results resCurrExe)) { - if ( resExe > resCurrExe) { - dctErr[taskId] = resExe ; - pattInfo.SetTaskState( cutId, taskId, resExe, sMsg) ; - } - } - else { - dctErr[taskId] = resExe ; - pattInfo.SetTaskState( cutId, taskId, resExe, sMsg) ; - } - } - // altrimenti per feature generica - else { - pattInfo.SetTaskState( cutId, taskId, resExe, sMsg) ; - } - // gestione rotazione per feature identificata - if ( taskId != 0) { - // verifiche per feature con più parti - if ( dctRot.TryGetValue( taskId, out double dCurrRot)) { - if ( Math.Abs( dRot) > 1) { - if ( Math.Abs( dCurrRot) < 1) - dctRot[taskId] = dRot ; - } - else { - dRot = dCurrRot ; - } - } - else { - dctRot.Add( taskId, dRot) ; - } - } - // imposto la rotazione - if ( pattInfo.IsFromProject) - pattInfo.SetProcessInfoChosen( cutId, taskId, dRot, 0, false) ; - else - pattInfo.SetTaskInfoChosen( cutId, taskId, dRot, 0, false) ; - } - else if ( line.StartsWith( "TIME=")) { - int? nVal = GetVal( line, "TIME") ; - nTotTime = ( nVal != null ? nVal.Value : 0) ; - } - else if ( ! string.IsNullOrWhiteSpace( line) && line != "---") - sMsg = line ; - } - } - else { - bErrors = true ; - nLastErr = 25 ; - sLastMsg = "Execution Error" ; - } - pattInfo.IsDone = true ; - if ( ! bErrors) { - pattInfo.Result = PatternInfo.Results.OK ; - pattInfo.DetailResult = PatternInfo.DetailResults.MEMORY ; - } - else { - // Sezione oltre i limiti - if ( nLastErr == 17) { - pattInfo.Result = PatternInfo.Results.ERROR ; - pattInfo.DetailResult = PatternInfo.DetailResults.ALL_WARNING ; - pattInfo.Message = sLastMsg ; - } - // Errore nel calcolo lavorazione o movimento carrelli - else if ( nLastErr == 19) { - pattInfo.Result = PatternInfo.Results.ERROR ; - pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR ; - pattInfo.Message = sLastMsg ; - } - // Collisione non assegnata ad una feature - else if ( nLastErr == 22) { - pattInfo.Result = PatternInfo.Results.ERROR ; - pattInfo.DetailResult = PatternInfo.DetailResults.ALL_COLLISION ; - pattInfo.Message = sLastMsg ; - } - // Extra corsa assi - else if ( nLastErr == 23) { - pattInfo.Result = PatternInfo.Results.ERROR ; - pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR ; - pattInfo.Message = sLastMsg ; - } - // Carri che scivolano sulla trave - else if ( nLastErr == 24) { - pattInfo.Result = PatternInfo.Results.ERROR ; - pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR ; - pattInfo.Message = sLastMsg ; - } - // Errore generico - else if ( nLastErr == 25) { - pattInfo.Result = PatternInfo.Results.ERROR ; - pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR ; - pattInfo.Message = sLastMsg ; - } - // Altro - else { - pattInfo.Result = PatternInfo.Results.ERROR ; - pattInfo.DetailResult = PatternInfo.DetailResults.MEMORY ; - } - } - pattInfo.EstimatedTime = nTotTime ; - - // Lettura OutputFilename e scrittura nel parametro stringa Iso (caso UIModes.HIDDEN) - if ( ! bErrors && - ( UIMode == InOutParameters.UIModes.HIDDEN || UIMode == InOutParameters.UIModes.CLOUD)) { - - string CncPath = Path.ChangeExtension( BtlPath, ".cnc") ; - if ( File.Exists( CncPath)) { - string lines = System.IO.File.ReadAllText(CncPath) ; - pattInfo.Iso = lines ; - pattInfo.Result = PatternInfo.Results.OK ; - pattInfo.DetailResult = PatternInfo.DetailResults.ALL_OK ; - } - else { - pattInfo.Iso = "" ; - pattInfo.Result = PatternInfo.Results.ERROR ; - pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR ; - } - } - } - - //------------------------------------------------------------------------------------------------------------- - // Il seguente metodo prende i record visualizzati in ds (Caso: Produzione) e li carica in un oggetto BTL - public static void GetListaTasks( BTL btlObject) - { - DataTable dTab = _ds.Tables[0] ; - Int32 listaTasksCount = dTab.Rows.Count ; - if ( listaTasksCount == 0) - return ; - - DataRow dRow0 = dTab.Rows[0] ; - btlObject.projectNumber = dRow0["projectId"].ToString() ; - btlObject.barLength = GetBarLengthP( (int)dRow0["patternId"], (int)dRow0["productionId"]).ToString( "F3", CultureInfo.InvariantCulture) ; - btlObject.barLoad90 = GetBarLoad90P( (int)dRow0["patternId"], (int)dRow0["productionId"]).ToString( CultureInfo.InvariantCulture) ; - btlObject.panelLength = GetBarLengthP( (int)dRow0["patternId"], (int)dRow0["productionId"]).ToString( "F3", CultureInfo.InvariantCulture) ; - btlObject.panelWidth = GetBarWidthP( (int)dRow0["patternId"], (int)dRow0["productionId"]).ToString( "F3", CultureInfo.InvariantCulture) ; - btlObject.productionId = (int)dRow0["productionId"] ; - btlObject.patternId = (int)dRow0["patternId"] ; - btlObject.parts = new List() ; - - List ListaCutParts = GetListaCutIdP() ; - - for ( int c = 0 ; c < ListaCutParts.Count ; c++) { - - BTL.Part readPart = new BTL.Part() ; - - bool bFirst = true ; - for ( int f = 0; f < listaTasksCount; f++) { - - DataRow dRowF = dTab.Rows[f] ; - if ( (int)dRowF["cutId"] != ListaCutParts[c]) - continue ; - - if ( bFirst) { - readPart.singleMemberNumber = GetElementSN( (int)dRowF["elementId"], (int)dRowF["projectId"]) ; - readPart.count = "1" ; - readPart.length = dRowF["length"].ToString() ; - readPart.height = dRowF["height"].ToString() ; - readPart.width = dRowF["width"].ToString() ; - readPart.x = (double)dRowF["x"] ; - readPart.z = (double)dRowF["z"] ; - readPart.inverted = (double)dRowF["inverted"] ; - readPart.rotated = (double)dRowF["rotated"] ; - readPart.cutId = (int)dRowF["cutId"] ; - bFirst = false ; - readPart.features = new List() ; - } - - if ( string.IsNullOrEmpty( dRowF["taskId"].ToString())) - continue ; - - BTL.Feature readFeature = new BTL.Feature() { - taskId = dRowF["taskId"].ToString(), - processKey = dRowF["group"].ToString() + - "-" + dRowF["key"].ToString().Substring( 1, 3) + - "-" + dRowF["face"].ToString(), - designation = dRowF["des"].ToString(), - processIdent = dRowF["processIdent"].ToString(), - sag1 = dRowF["sag1"].ToString(), - text = dRowF["text"].ToString(), - process = ( Convert.ToInt16( dRowF["enabled"]) == 1) ? "YES" : "NO", - processParameters = new List( 46) { - dRowF["p01"].ToString(), - dRowF["p02"].ToString(), - dRowF["p03"].ToString(), - dRowF["p04"].ToString(), - dRowF["p05"].ToString(), - dRowF["p06"].ToString(), - dRowF["p07"].ToString(), - dRowF["p08"].ToString(), - dRowF["p09"].ToString(), - dRowF["p10"].ToString(), - dRowF["p11"].ToString(), - dRowF["p12"].ToString(), - dRowF["p13"].ToString(), - dRowF["p14"].ToString(), - dRowF["p15"].ToString(), - dRowF["p16"].ToString(), - dRowF["p17"].ToString(), - dRowF["p18"].ToString(), - dRowF["p19"].ToString(), - dRowF["p20"].ToString(), - dRowF["p21"].ToString(), - dRowF["p22"].ToString(), - dRowF["p23"].ToString(), - dRowF["p24"].ToString(), - dRowF["p25"].ToString(), - dRowF["p26"].ToString(), - dRowF["q01"].ToString(), - dRowF["q02"].ToString(), - dRowF["q03"].ToString(), - dRowF["q04"].ToString(), - dRowF["q05"].ToString(), - dRowF["q06"].ToString(), - dRowF["q07"].ToString(), - dRowF["q08"].ToString(), - dRowF["q09"].ToString(), - dRowF["q10"].ToString(), - dRowF["q11"].ToString(), - dRowF["q12"].ToString(), - dRowF["q13"].ToString(), - dRowF["q14"].ToString(), - dRowF["q15"].ToString(), - dRowF["q16"].ToString(), - dRowF["q17"].ToString(), - dRowF["q18"].ToString(), - dRowF["q19"].ToString(), - dRowF["q20"].ToString() - }, - processReference = new List( 9) { - dRowF["ox"].ToString(), - dRowF["oy"].ToString(), - dRowF["oz"].ToString(), - dRowF["xx"].ToString(), - dRowF["xy"].ToString(), - dRowF["xz"].ToString(), - dRowF["yx"].ToString(), - dRowF["yy"].ToString(), - dRowF["yz"].ToString() - }, - } ; - readPart.features.Add( readFeature) ; - } - btlObject.parts.Add( readPart) ; - } - // L'ordinamento delle Part in un oggetto BTL avviene col confronto del parametro x, estratto dalla tabella vw_Cut - btlObject.parts.Sort( (p, q) => p.x.CompareTo( q.x)) ; - } - - //------------------------------------------------------------------------------------------------------------- - private static int? GetVal( string sText, string sKey) - { - string[] sParts = sText.Split( new Char[] { '=' }) ; - if ( string.Compare( sParts[0], sKey) != 0) - return null ; - if ( ! int.TryParse( sParts[1], out int nVal)) - return null ; - else - return nVal ; - } - - //------------------------------------------------------------------------------------------------------------- - // Il seguente metodo prende i record visualizzati in ds (Caso: Ordine) e li carica in un oggetto BTL - public static void GetListaProcesses( BTL btlObject) - { - DataTable dTab = _ds.Tables[0] ; - int listaProcessesCount = dTab.Rows.Count ; - if ( listaProcessesCount == 0) { - btlObject.parts = null ; - return ; - } - - DataRow dRow0 = dTab.Rows[0] ; - btlObject.projectNumber = dRow0["projectId"].ToString() ; - btlObject.barLength = GetBarLengthO( (int)dRow0["elementId"], (int)dRow0["projectId"]).ToString( "F3", CultureInfo.InvariantCulture) ; - btlObject.barLoad90 = "0" ; - btlObject.panelLength = GetPanelLengthO( (int)dRow0["elementId"], (int)dRow0["projectId"]).ToString( "F3", CultureInfo.InvariantCulture) ; - btlObject.panelWidth = GetPanelWidthO( (int)dRow0["elementId"], (int)dRow0["projectId"]).ToString( "F3", CultureInfo.InvariantCulture) ; - btlObject.projectId = (int)dRow0["projectId"] ; - btlObject.elementId = (int)dRow0["elementId"] ; - btlObject.parts = new List() ; - - List ListaCutParts = new List( 1) ; - ListaCutParts.Add( (int)dRow0["elementId"]) ; - - for ( int c = 0 ; c < ListaCutParts.Count ; c++) { - - BTL.Part readPart = new BTL.Part() ; - - bool bFirst = true ; - for ( int f = 0 ; f < listaProcessesCount ; f++) { - - DataRow dRowF = dTab.Rows[f] ; - if ( (int)dRowF["elementId"] != ListaCutParts[c]) - continue ; - - if ( bFirst) { - readPart.singleMemberNumber = GetElementSN( (int)dRow0["elementId"], (int)dRow0["projectId"]) ; - readPart.count = "1" ; - readPart.length = dRowF["length"].ToString() ; - readPart.height = dRowF["height"].ToString() ; - readPart.width = dRowF["width"].ToString() ; - readPart.x = Constants.HeadOverMat ; - readPart.z = Constants.HeadOverMat ; - readPart.inverted = (double)dRowF["inverted"] ; - readPart.rotated = (double)dRowF["rotated"] ; - readPart.elementId = (int)dRowF["elementId"] ; - bFirst = false ; - readPart.features = new List() ; - } - - if ( string.IsNullOrEmpty( dRowF["processId"].ToString())) - continue ; - - BTL.Feature readFeature = new BTL.Feature() { - processId = dRowF["processId"].ToString(), - processKey = dRowF["group"].ToString() + - "-" + dRowF["key"].ToString().Substring( 1, 3) + - "-" + dRowF["face"].ToString(), - designation = dRowF["des"].ToString(), - processIdent = dRowF["processIdent"].ToString(), - sag1 = dRowF["sag1"].ToString(), - text = dRowF["text"].ToString(), - process = ( Convert.ToInt16( dRowF["enabled"]) == 1) ? "YES" : "NO", - processParameters = new List( 46) { - dRowF["p01"].ToString(), - dRowF["p02"].ToString(), - dRowF["p03"].ToString(), - dRowF["p04"].ToString(), - dRowF["p05"].ToString(), - dRowF["p06"].ToString(), - dRowF["p07"].ToString(), - dRowF["p08"].ToString(), - dRowF["p09"].ToString(), - dRowF["p10"].ToString(), - dRowF["p11"].ToString(), - dRowF["p12"].ToString(), - dRowF["p13"].ToString(), - dRowF["p14"].ToString(), - dRowF["p15"].ToString(), - dRowF["p16"].ToString(), - dRowF["p17"].ToString(), - dRowF["p18"].ToString(), - dRowF["p19"].ToString(), - dRowF["p20"].ToString(), - dRowF["p21"].ToString(), - dRowF["p22"].ToString(), - dRowF["p23"].ToString(), - dRowF["p24"].ToString(), - dRowF["p25"].ToString(), - dRowF["p26"].ToString(), - dRowF["q01"].ToString(), - dRowF["q02"].ToString(), - dRowF["q03"].ToString(), - dRowF["q04"].ToString(), - dRowF["q05"].ToString(), - dRowF["q06"].ToString(), - dRowF["q07"].ToString(), - dRowF["q08"].ToString(), - dRowF["q09"].ToString(), - dRowF["q10"].ToString(), - dRowF["q11"].ToString(), - dRowF["q12"].ToString(), - dRowF["q13"].ToString(), - dRowF["q14"].ToString(), - dRowF["q15"].ToString(), - dRowF["q16"].ToString(), - dRowF["q17"].ToString(), - dRowF["q18"].ToString(), - dRowF["q19"].ToString(), - dRowF["q20"].ToString() - }, - processReference = new List( 9) { - dRowF["ox"].ToString(), - dRowF["oy"].ToString(), - dRowF["oz"].ToString(), - dRowF["xx"].ToString(), - dRowF["xy"].ToString(), - dRowF["xz"].ToString(), - dRowF["yx"].ToString(), - dRowF["yy"].ToString(), - dRowF["yz"].ToString() - }, - } ; - readPart.features.Add( readFeature) ; - } - btlObject.parts.Add( readPart) ; - } - // L'ordinamento delle Part in un oggetto BTL avviene col confronto del parametro x, estratto dalla tabella vw_Cut - btlObject.parts.Sort( (p, q) => p.x.CompareTo( q.x)) ; - } - - //------------------------------------------------------------------------------------------------------------- - // Il seguente metodo si connette al DB per estrarre tramite una query i cutId della tabella vw_Cut - // aventi patternId e ProductionId che corrispondono a quelli passati come argomento - private static List GetListaCutIdP() - { - List ListaCutId = new List() ; - - DataTable dTab = _ds.Tables[0] ; - int listaTasksCount = dTab.Rows.Count ; - for ( int f = 0 ; f < listaTasksCount ; f++) { - int nCut = (int) dTab.Rows[f]["cutId"] ; - if ( ! ListaCutId.Contains( nCut)) - ListaCutId.Add( nCut) ; - } - - return ListaCutId ; - } - - //------------------------------------------------------------------------------------------------------------- - // Recupera il singlemembernumber dell'Elemento (colonna "sn") - private static string GetElementSN( int ElementId, int ProjectId) - { - string SN = "000" ; - - string sqlElementSN = "SELECT sn " + - "FROM dbo.vw_Element " + - "WHERE elementId = @firstId " + - "AND projectId = @secondId" ; - - // Connessione al DB ed esecuzione query - using ( SqlConnection cn = new SqlConnection( _SqlConnectionStr)) { - cn.Open() ; - using ( SqlCommand sqlCommand = new SqlCommand( sqlElementSN, cn)) { - sqlCommand.Parameters.Add( "@firstId", SqlDbType.Int) ; - sqlCommand.Parameters.Add( "@secondId", SqlDbType.Int) ; - sqlCommand.Parameters["@firstId"].Value = ElementId ; - sqlCommand.Parameters["@secondId"].Value = ProjectId ; - SqlDataReader reader = sqlCommand.ExecuteReader() ; - while ( reader.Read()) { - SN = Convert.ToString( reader["sn"]) ; - } - } - } - - return SN ; - } - - //------------------------------------------------------------------------------------------------------------- - // Recupera la lunghezza della barra nel caso Produzione (colonna "l") - private static double GetBarLengthP( int patternId, int productionId) - { - double barLength = 0 ; - - string sqlBarLength = "SELECT l " + - "FROM dbo.vw_Pattern " + - "WHERE patternId = @firstId " + - "AND productionId = @secondId" ; - - // Connessione al DB ed esecuzione query - using ( SqlConnection cn = new SqlConnection( _SqlConnectionStr)) { - cn.Open() ; - using ( SqlCommand sqlCommand = new SqlCommand( sqlBarLength, cn)) { - sqlCommand.Parameters.Add( "@firstId", SqlDbType.Int) ; - sqlCommand.Parameters.Add( "@secondId", SqlDbType.Int) ; - sqlCommand.Parameters["@firstId"].Value = patternId ; - sqlCommand.Parameters["@secondId"].Value = productionId ; - SqlDataReader reader = sqlCommand.ExecuteReader() ; - while ( reader.Read()) { - barLength = Convert.ToDouble( reader["l"]) ; - } - } - } - - return barLength ; - } - - //------------------------------------------------------------------------------------------------------------- - // Recupera la larghezza della barra nel caso Produzione (colonna "w") - private static double GetBarWidthP( int patternId, int productionId) - { - double barWidth = 0 ; - - string sqlBarWidth = "SELECT w " + - "FROM dbo.vw_Pattern " + - "WHERE patternId = @firstId " + - "AND productionId = @secondId" ; - - // Connessione al DB ed esecuzione query - using ( SqlConnection cn = new SqlConnection( _SqlConnectionStr)) { - cn.Open() ; - using ( SqlCommand sqlCommand = new SqlCommand( sqlBarWidth, cn)) { - sqlCommand.Parameters.Add( "@firstId", SqlDbType.Int) ; - sqlCommand.Parameters.Add( "@secondId", SqlDbType.Int) ; - sqlCommand.Parameters["@firstId"].Value = patternId ; - sqlCommand.Parameters["@secondId"].Value = productionId ; - SqlDataReader reader = sqlCommand.ExecuteReader() ; - while ( reader.Read()) { - barWidth = Convert.ToDouble( reader["w"]) ; - } - } - } - - return barWidth ; - } - - //------------------------------------------------------------------------------------------------------------- - // Recupera il flag di carico con rotazione di 90° nel caso Produzione (colonna "load90") - private static int GetBarLoad90P( int patternId, int productionId) - { - int nLoad90 = 0 ; - - string sqlBarLength = "SELECT load90 " + - "FROM dbo.vw_Pattern " + - "WHERE patternId = @firstId " + - "AND productionId = @secondId" ; - - // Connessione al DB ed esecuzione query - using ( SqlConnection cn = new SqlConnection( _SqlConnectionStr)) { - cn.Open() ; - using ( SqlCommand sqlCommand = new SqlCommand( sqlBarLength, cn)) { - sqlCommand.Parameters.Add( "@firstId", SqlDbType.Int) ; - sqlCommand.Parameters.Add( "@secondId", SqlDbType.Int) ; - sqlCommand.Parameters["@firstId"].Value = patternId ; - sqlCommand.Parameters["@secondId"].Value = productionId ; - SqlDataReader reader = sqlCommand.ExecuteReader() ; - while ( reader.Read()) { - nLoad90 = Convert.ToInt32( reader["load90"]) ; - } - } - } - - return nLoad90 ; - } - - //------------------------------------------------------------------------------------------------------------- - // Recupera lo stato della barra nel caso Produzione (colonna "state") - private static int GetBarStateP( int patternId, int productionId) - { - int barState = 16 ; - - string sqlBarLength = "SELECT state " + - "FROM dbo.vw_Pattern " + - "WHERE patternId = @firstId " + - "AND productionId = @secondId" ; - - // Connessione al DB ed esecuzione query - using ( SqlConnection cn = new SqlConnection( _SqlConnectionStr)) { - cn.Open() ; - using ( SqlCommand sqlCommand = new SqlCommand( sqlBarLength, cn)) { - sqlCommand.Parameters.Add( "@firstId", SqlDbType.Int) ; - sqlCommand.Parameters.Add( "@secondId", SqlDbType.Int) ; - sqlCommand.Parameters["@firstId"].Value = patternId ; - sqlCommand.Parameters["@secondId"].Value = productionId ; - SqlDataReader reader = sqlCommand.ExecuteReader() ; - while ( reader.Read()) { - barState = Convert.ToInt32( reader["state"]) ; - } - } - } - - return barState ; - } - - //------------------------------------------------------------------------------------------------------------- - // Recupera la lunghezza della barra nel caso Ordine (colonna "length", ovvero la lunghezza della singola trave) - // a cui aggiungiamo un valore fisso (es. 2000) - private static double GetBarLengthO( int elementId, int projectId) - { - double barLength = 0 ; - - DataTable dTab = _ds.Tables[0] ; - int listaProcessesCount = dTab.Rows.Count ; - if ( listaProcessesCount > 0) { - double beamLength = Convert.ToDouble( dTab.Rows[0]["length"]) ; - if ( beamLength < Constants.BarMaxLenForAdd) - barLength = beamLength + Constants.BarAddLen ; - else - barLength = beamLength + 2 * Constants.HeadOverMat ; - } - - return barLength ; - } - - //------------------------------------------------------------------------------------------------------------- - // Recupera la lunghezza del pannello nel caso Ordine (colonna "length", ovvero la lunghezza della singola parete) - // a cui aggiungiamo un valore fisso (es. 200) - private static double GetPanelLengthO( int elementId, int projectId) - { - double panelLength = 0 ; - - DataTable dTab = _ds.Tables[0] ; - int listaProcessesCount = dTab.Rows.Count ; - if ( listaProcessesCount > 0) { - double wallLength = Convert.ToDouble( dTab.Rows[0]["length"]) ; - panelLength = wallLength + 2 * Constants.PanelOverMat ; - } - - return panelLength ; - } - - //------------------------------------------------------------------------------------------------------------- - // Recupera la lunghezza del pannello nel caso Ordine (colonna "width", ovvero la larghezza della singola parete) - // a cui aggiungiamo un valore fisso (es. 200) - private static double GetPanelWidthO( int elementId, int projectId) - { - double panelWidth = 0 ; - - DataTable dTab = _ds.Tables[0] ; - int listaProcessesCount = dTab.Rows.Count ; - if ( listaProcessesCount > 0) { - double wallWidth = Convert.ToDouble( dTab.Rows[0]["width"]) ; - panelWidth = wallWidth + 2 * Constants.PanelOverMat ; - } - - return panelWidth ; - } - - //------------------------------------------------------------------------------------------------------------- - // Restituisce la path di esecuzione di EgtCam5 - private static String GetExePath( InOutParameters parameters) - { - return parameters.Read( "EGALTECH", "PATH_EXE", "") ; - } - - //------------------------------------------------------------------------------------------------------------- - // Restituisce il direttorio per i file con i dati macchina - private static String GetDataDir( InOutParameters parameters) - { - String DataDir = parameters.Read( "EGALTECH", "DIR_DATA", "") ; - // Se la directory non esiste viene creata - DirectoryInfo di = new DirectoryInfo( DataDir) ; - if ( ! di.Exists) - di.Create() ; - return DataDir ; - } - - //------------------------------------------------------------------------------------------------------------- - // Restituisce la path completa per il file BTL - private static String GetBtlPath( String DataDir, PatternInfo pattInfo) - { - String BtlDir, BtlName ; - // Se progetto - if ( pattInfo.IsFromProject) { - BtlDir = Path.Combine( DataDir, "Projs", pattInfo.ProjectId.ToString( "D4")) ; - BtlName = "Part_" + pattInfo.ProjectId.ToString() + "_" + pattInfo.ElementId.ToString() + ".btl" ; - } - // altrimenti produzione - else { - BtlDir = Path.Combine( DataDir, "Prods", pattInfo.ProductionId.ToString( "D4")) ; - BtlName = "Bar_" + pattInfo.ProductionId.ToString() + "_" + pattInfo.PatternId.ToString() + ".btl" ; - } - // Se la directory non esiste viene creata - DirectoryInfo di = new DirectoryInfo( BtlDir) ; - if ( ! di.Exists) - di.Create() ; - // restituisco la path completa - return Path.Combine( BtlDir, BtlName) ; - } - - //------------------------------------------------------------------------------------------------------------- - // Restituisce il massimo numero di istanze di EgtCAM5 eseguibili contemporaneamente - private static int GetMaxInstances( InOutParameters parameters) - { - String sMaxInst = parameters.Read( "EGALTECH", "MaxInstances", "1") ; - if ( ! int.TryParse( sMaxInst, out int nVal)) - return 1 ; - else - return Math.Max( nVal, 1) ; - } - - //------------------------------------------------------------------------------------------------------------- - // Visualizzazione finestra gestione DB utensili - public bool ShowTools( InOutParameters parameters) - { - // Recupero dati - string ExePath = GetExePath( parameters) ; - string DataDir = GetDataDir( parameters) ; - string BtlPath = Path.Combine( DataDir, "QQQ.btl") ; - // Esecuzione di EgtCAM5 con parametri path BTL, nome macchina e modo - Process process = new Process() ; - process.StartInfo.FileName = ExePath ; - process.StartInfo.Arguments = "\"" + BtlPath + "\" " + parameters.MachineName + " 11" ; - process.StartInfo.UseShellExecute = false ; - process.Start() ; - // Attendo il termine del processo - while ( ! process.HasExited) { - process.Refresh() ; - Thread.Sleep( 50) ; - } - return true ; - } - - //------------------------------------------------------------------------------------------------------------- - // Visualizzazione finestra gestione DB lavorazioni - public bool ShowJobs( InOutParameters parameters) - { - // Recupero dati - string ExePath = GetExePath( parameters) ; - string DataDir = GetDataDir( parameters) ; - string BtlPath = Path.Combine( DataDir, "QQQ.btl") ; - // Esecuzione di EgtCAM5 con parametri path BTL, nome macchina e modo - Process process = new Process() ; - process.StartInfo.FileName = ExePath ; - process.StartInfo.Arguments = "\"" + BtlPath + "\" " + parameters.MachineName + " 12" ; - process.StartInfo.UseShellExecute = false ; - process.Start() ; - // Attendo il termine del processo - while ( ! process.HasExited) { - process.Refresh() ; - Thread.Sleep( 50) ; - } - return true ; - } - - //------------------------------------------------------------------------------------------------------------- - // Aggiornamento dati macchina - public bool UpdateMachine( InOutParameters parameters) - { - GetMachineParams( parameters) ; - - return true ; - } - - //------------------------------------------------------------------------------------------------------------- - // Dati utensili e macchina - //------------------------------------------------------------------------------------------------------------- - // Import della funzione di sistema per la scrittura su file INI - [DllImport("kernel32", CharSet = CharSet.Unicode)] - static extern long WritePrivateProfileString( string Section, string Key, string Value, string FilePath) ; - - //------------------------------------------------------------------------------------------------------------- - // Scrive il file Essetre-[MachineName].data che riporta i parametri macchina del DB - private static void GetMachineParams( InOutParameters parameters) - { - // Direttorio di scrittura del file - String DataDir = GetDataDir( parameters) ; - - // Path del file di dati e sua cancellazione se già esiste - string DataName = "Essetre-" + parameters.MachineName + ".data" ; - string DataPath = Path.Combine( DataDir, DataName) ; - if ( File.Exists( DataPath)) - File.Delete( DataPath) ; - - // Preparazione interrogazione per Offsets del DB - _SqlConnectionStr = parameters.ConnectionString ; - DataSet dsOffsets = new DataSet() ; - - string sqlOffsets = "SELECT [group], [key], [value] " + - "FROM [ESSETRE].[dbo].[vw_MachineParam] " + - "WHERE [group] = 'OFFSETS' AND configurationId = @ConfigId" ; - - // Connessione al DB ed esecuzione query - using ( SqlConnection cn = new SqlConnection(_SqlConnectionStr)) { - cn.Open() ; - using ( SqlCommand cmd = new SqlCommand(sqlOffsets, cn)) { - cmd.Parameters.Add( "@ConfigId", SqlDbType.Int) ; - cmd.Parameters["@ConfigId"].Value = parameters.ConfigurationId ; - var dataAdapter = new SqlDataAdapter( cmd) ; - // Lettura DB e riempimento DataSet - dsOffsets.Clear() ; - dataAdapter.Fill(dsOffsets) ; - } - } - - // Preparazione interrogazione per Trave del DB - _SqlConnectionStr = parameters.ConnectionString ; - DataSet dsTrave = new DataSet() ; - - string sqlTrave = "SELECT [group], [key], [value] " + - "FROM [ESSETRE].[dbo].[vw_MachineParam] " + - "WHERE [group] = 'TRAVE' AND configurationId = @ConfigId" ; - - // Connessione al DB ed esecuzione query - using ( SqlConnection cn = new SqlConnection(_SqlConnectionStr)) { - cn.Open() ; - using ( SqlCommand cmd = new SqlCommand( sqlTrave, cn)) { - cmd.Parameters.Add( "@ConfigId", SqlDbType.Int) ; - cmd.Parameters["@ConfigId"].Value = parameters.ConfigurationId ; - var dataAdapter = new SqlDataAdapter( cmd) ; - // Lettura DB e riempimento DataSet - dsTrave.Clear() ; - dataAdapter.Fill( dsTrave) ; - } - } - - // Preparazione interrogazione per Dati Utente del DB - _SqlConnectionStr = parameters.ConnectionString; - DataSet dsUser = new DataSet(); - - string sqlUser = "SELECT [group], [key], [value] " + - "FROM [ESSETRE].[dbo].[vw_ConfigurationParam] " + - "WHERE [group] <> 'TEXTS' AND [group] <> 'PARAMS' AND configurationId = @ConfigId"; - - // Connessione al DB ed esecuzione query - using (SqlConnection cn = new SqlConnection(_SqlConnectionStr)) - { - cn.Open(); - using (SqlCommand cmd = new SqlCommand(sqlUser, cn)) - { - cmd.Parameters.Add("@ConfigId", SqlDbType.Int); - cmd.Parameters["@ConfigId"].Value = parameters.ConfigurationId; - var dataAdapter = new SqlDataAdapter(cmd); - // Lettura DB e riempimento DataSet - dsUser.Clear(); - dataAdapter.Fill(dsUser); - } - } - - // Apro file - using ( var tw = new StreamWriter( DataPath, false)) { - - // Scrittura intestazione - tw.WriteLine( "-- " + DataPath) ; - tw.WriteLine( "") ; - - // Scrittura dei dati di Offsets - tw.WriteLine( "local Offsets = {") ; - foreach ( DataTable table in dsOffsets.Tables) { - foreach ( DataRow row in table.Rows) { - String Key = row["key"].ToString() ; - String Value = row["value"].ToString() ; - tw.WriteLine( " " + Key + "=" + Value + ",") ; - } - } - tw.WriteLine( " Zzz=1") ; - tw.WriteLine( "}") ; - tw.WriteLine( "") ; - - // Scrittura dei dati di Trave - tw.WriteLine( "local Trave = {") ; - foreach ( DataTable table in dsTrave.Tables) { - foreach ( DataRow row in table.Rows) { - String Key = row["key"].ToString() ; - String Value = row["value"].ToString() ; - tw.WriteLine( " " + Key + "=" + Value + ",") ; - } - } - tw.WriteLine( " Zzz=1") ; - tw.WriteLine( "}") ; - tw.WriteLine( "") ; - - // Scrittura dei dati di Utente - tw.WriteLine("local User = {"); - foreach (DataTable table in dsUser.Tables) - { - foreach (DataRow row in table.Rows) - { - String Group = row["group"].ToString(); - String Key = row["key"].ToString(); - String Value = row["value"].ToString(); - tw.WriteLine(" " + Group + "_" + Key + "=" + Value + ","); - } - } - tw.WriteLine(" Zzz=1"); - tw.WriteLine("}"); - tw.WriteLine(""); - - // Scrittura tabella da restituire - tw.WriteLine( "local Machine = { Offsets=Offsets, Trave=Trave, User=User}") ; - - tw.WriteLine( "return Machine") ; - } - } - - //------------------------------------------------------------------------------------------------------------- - // Indica direttori e file per backup - public void CollectFile( InOutParameters parameters, FileCollector collector) - { - // Direttori notevoli - String sRoot = parameters.Read( "EGALTECH", "DIR_EGT", "C:\\TechnoEssetre7\\EgalTech") ; - String sBeamDir = "EgtCAM5\\Beam" ; - String sMachDir = "EgtCAM5\\Machines\\Essetre-" + parameters.MachineName ; - // Impostazione - collector.SetRoot(sRoot) ; - collector.AddDirectory(Path.Combine(sRoot, sBeamDir)) ; - collector.AddDirectory(Path.Combine(sRoot, sMachDir)) ; - } - -} diff --git a/EgtBEAMWALL.ViewerOptimizer/Integration/Generator.orig.cs b/EgtBEAMWALL.ViewerOptimizer/Integration/Generator.orig.cs deleted file mode 100644 index f8b3417b..00000000 --- a/EgtBEAMWALL.ViewerOptimizer/Integration/Generator.orig.cs +++ /dev/null @@ -1,1276 +0,0 @@ -using System; -using System.Windows.Forms; -using System.Collections.Generic; -using System.Data; -using System.Data.SqlClient; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using System.Globalization ; -using ib.essetre.integration; -using ib.essetre.integration.egaltech; - -namespace ib.essetre.integration.egaltech -{ - public class Generator : ib.essetre.integration.IGenerator - { - private System.Threading.Thread _thread ; - private static DataSet _ds = new DataSet() ; - private static string _SqlConnectionStr = "" ; - - private struct Bar - { - public PatternInfo piInfo ; - public int nBarState ; - public string sBtlPath ; - public bool bBtlOk ; - } - - private struct MyProc - { - public bool bEnable ; - public Process Proc ; - public int nBar ; - } - - //------------------------------------------------------------------------------------------------------------- - public Generator() - { - } - - //------------------------------------------------------------------------------------------------------------- - public void Run(InOutParameters parameters, ICallBack callback) - { - _thread = new Thread(() => DoJob( parameters, callback)) ; - _thread.Start() ; - } - - private delegate void dDoJob( InOutParameters parameters, ICallBack callback) ; - - //------------------------------------------------------------------------------------------------------------- - // campo data ultima modifica nel DATABASE [lastModified] - private static void DoJob( InOutParameters parameters, ICallBack callback) - { - bool bCancel = false ; - callback.Progress( 0, "Init", ref bCancel) ; - - _SqlConnectionStr = parameters.ConnectionString ; - - String ExePath = GetExePath( parameters) ; - String DataDir = GetDataDir( parameters) ; - - // Numero di barre - int numBars = parameters.Patterns.Length ; - if ( numBars == 0) - return ; - - // Se modalità Cloud, allora conta solo la prima barra - bool bCloud = ( parameters.UIMode == InOutParameters.UIModes.CLOUD) ; - if ( bCloud) - numBars = 1 ; - - // Numero di core logici da utilizzare (minimo tra presenti sul PC e imposti da INI) - int nMaxThread = Math.Min( Environment.ProcessorCount, GetMaxInstances( parameters)) ; - - // Frazione di avanzamento del lavoro (in pu) - double dProgress = 0 ; - - // Genero i Btl di tutte le barre - Bar[] vBar = new Bar[ numBars + nMaxThread] ; - for ( int i = 0; i < numBars; i++) { - - PatternInfo pattInfo = parameters.Patterns[i] ; - - BTL btlObject = new BTL() ; - - // Se il parametro IsFromProject è TRUE viene eseguita la query sulle tabelle Project, - // se invece è FALSE viene eseguita la query sulle tabelle Production - string sql = "" ; - if ( pattInfo.IsFromProject) { - sql = "SELECT E.projectId, " + - "E.elementId, 0 cutId, processId, info1, info2, enabled, level, " + - "inTools, outTools, isChecked, P.done, isoType, ax, ay, az, P.x, P.y, P.z, " + - "P.flagDeleted, P.[group], [key], face, edge, des, " + - "p01, p02, p03, p04, p05, p06, p07, p08, p09, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, " + - "q01, q02, q03, q04, q05, q06, q07, q08, q09, q10, q11, q12, q13, q14, q15, q16, q17, q18, q19, q20, " + - "ox, oy, oz, xx, xy, xz, yx, yy, yz, " + - "priority, processIdent, processingQuality, sag1, text, E.projectId, E.elementId, P.processId, 0 cutStart, 0 cutEnd, " + - "E.inverted, E.rotated, 0 doneTime, 0 startAngle, 0 endAngle, -1 referenceCutId, E.length, E.width, E.height " + - "FROM dbo.vw_Process AS P " + - "RIGHT OUTER JOIN dbo.vw_Element AS E " + - "ON P.projectId=E.projectId AND P.elementId=E.elementId " + - "WHERE E.projectId = @firstId AND E.elementId = @secondId" ; - } - else { - sql = "SELECT vw_Cut.productionId, " + - "vw_Cut.patternId, vw_Cut.cutId, taskId, info1, info2, enabled, level, " + - "inTools, outTools, isChecked, vw_Task.done, isoType, ax, ay, az, vw_Cut.x, vw_Cut.y, vw_Cut.z, " + - "vw_Task.flagDeleted, [group], [key], face, edge, des, " + - "p01, p02, p03, p04, p05, p06, p07, p08, p09, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, " + - "q01, q02, q03, q04, q05, q06, q07, q08, q09, q10, q11, q12, q13, q14, q15, q16, q17, q18, q19, q20, " + - "ox, oy, oz, xx, xy, xz, yx, yy, yz, " + - "priority, processIdent, processingQuality, sag1, text, vw_Cut.projectId, vw_Cut.elementId, cutStart, cutEnd, " + - "inverted, rotated, doneTime, startAngle, endAngle, referenceCutId, length, width, height " + - "FROM dbo.vw_Task " + - "RIGHT OUTER JOIN dbo.vw_Cut " + - "ON (vw_Task.cutId = vw_Cut.cutId AND vw_Task.patternId = vw_Cut.patternId AND vw_Task.productionId = vw_Cut.productionId) " + - "WHERE vw_Cut.productionId = @firstId AND vw_Cut.patternId = @secondId" ; - } - - // Connessione al DB ed esecuzione query - using ( SqlConnection cn = new SqlConnection( _SqlConnectionStr)) { - cn.Open() ; - using (SqlCommand cmd = new SqlCommand( sql, cn)) { - cmd.Parameters.Add( "@firstId", SqlDbType.Int) ; - cmd.Parameters.Add( "@secondId", SqlDbType.Int) ; - if ( pattInfo.IsFromProject) { - cmd.Parameters["@firstId"].Value = pattInfo.ProjectId ; - cmd.Parameters["@secondId"].Value = pattInfo.ElementId ; - } - else { - cmd.Parameters["@firstId"].Value = pattInfo.ProductionId ; - cmd.Parameters["@secondId"].Value = pattInfo.PatternId ; - } - var dataAdapter = new SqlDataAdapter( cmd) ; - - // Lettura DB e riempimento DataSet - _ds.Clear() ; - dataAdapter.Fill( _ds) ; - } - } - - // Verifica parametro isFromProject: nel caso Ordine viene ottenuta la lista dei Process, - // nel caso Produzione viene ottenuta la lista dei Task - if ( pattInfo.IsFromProject) - GetListaProcesses( btlObject) ; - else - GetListaTasks( btlObject) ; - - // Recupero lo stato della barra - int nBarState = 0 ; - if ( ! pattInfo.IsFromProject) - nBarState = GetBarStateP( btlObject.patternId, btlObject.productionId) ; - - // Dialog con Progress Bar - dProgress += 0.1 / numBars ; - string sProg = ( dProgress * 100).ToString("F1", CultureInfo.InvariantCulture) ; - callback.Progress( (float) dProgress, - " Progress: " + sProg + "%" + "\n", - ref bCancel) ; - if ( bCancel) { - callback.Done( parameters) ; //fine - return ; - } - - // Scrittura del file BTL - // Path completa del nome del file da salvare - string BtlPath = GetBtlPath( DataDir, pattInfo) ; - bool BtlOk = btlObject.WriteIntoFile( BtlPath, pattInfo.IsFromProject) ; - - // Se modalità cloud, scrittura del file di punti - bool bErrOnCloud = false ; - if ( bCloud) { - if ( pattInfo.Cloud != null) { - using ( var tw = new StreamWriter( Path.ChangeExtension( BtlPath, ".pnt"), false)) { - for ( int j = 0 ; j < pattInfo.Cloud.Count() ; j++) { - double dPosX = - pattInfo.Cloud[j].Y ; - double dPosY = pattInfo.Cloud[j].X ; - string sPosX = dPosX.ToString( "0.00", System.Globalization.CultureInfo.InvariantCulture) ; - string sPosY = dPosY.ToString( "0.00", System.Globalization.CultureInfo.InvariantCulture) ; - tw.WriteLine( sPosX + " " + sPosY) ; - } - } - } - else { - BtlOk = false ; - bErrOnCloud = true ; - } - } - - // Se scrittura Btl non riuscita - if ( ! BtlOk) { - // scrivo direttamente il file di errore - int ErrCutId = ( pattInfo.IsFromProject ? pattInfo.ElementId : pattInfo.PatternId) ; - using ( var tw = new StreamWriter( Path.ChangeExtension( BtlPath, ".txt"), false)) { - tw.WriteLine( "ERR=10") ; - tw.WriteLine( bErrOnCloud ? "Cloud without points" : "BTL without processes") ; - tw.WriteLine( "CUTID=" + ErrCutId.ToString()) ; - tw.WriteLine( "TASKID=0") ; - } - // elimino eventuale file Cn già presente - if ( parameters.UIMode == InOutParameters.UIModes.HIDDEN) { - string CncPath = Path.ChangeExtension( BtlPath, ".cnc") ; - if ( File.Exists( CncPath)) - File.Delete( CncPath) ; - } - } - // altrimenti - else { - // cancello eventuale file di errore già presente - string TxtPath = Path.ChangeExtension( BtlPath, ".txt") ; - if ( File.Exists( TxtPath)) - File.Delete( TxtPath) ; - } - - // Salvo dati - vBar[i].piInfo = pattInfo ; - vBar[i].nBarState = nBarState ; - vBar[i].sBtlPath = BtlPath ; - vBar[i].bBtlOk = BtlOk ; - } - - // Lancio in parallelo più processi (senza superare il numero di core logici presenti) - MyProc[] vProc = new MyProc[nMaxThread] ; - for ( int j = 0 ; j < nMaxThread ; ++ j) { - vProc[j].nBar = -1 ; - vProc[j].bEnable = true ; - } - - // Processo i Btl in parallelo - int nCurrBar = 0 ; - int nDoneBar = 0 ; - int nShiftBar = 0 ; - int nActProc = 0 ; - while ( nCurrBar < numBars + nShiftBar || nActProc > 0) { - for ( int j = 0 ; j < nMaxThread ; ++ j) { - if ( ! vProc[j].bEnable) - continue ; - bool bDone = false ; - if ( vProc[j].nBar == -1) { - if ( nCurrBar < numBars + nShiftBar) { - if ( vBar[nCurrBar].bBtlOk) { - vProc[j].Proc = new Process() ; - vProc[j].Proc.StartInfo.FileName = ExePath ; - int nMode = (int)parameters.UIMode ; - if ( parameters.UIMode == InOutParameters.UIModes.HIDDEN && vBar[nCurrBar].nBarState != 0) - nMode = 4 ; - vProc[j].Proc.StartInfo.Arguments = "\"" + vBar[nCurrBar].sBtlPath + "\" " + parameters.MachineName + " " + nMode.ToString() ; - vProc[j].Proc.StartInfo.UseShellExecute = false ; - if ( vProc[j].Proc.Start()) { - vProc[j].nBar = nCurrBar ; - nCurrBar ++ ; - nActProc ++ ; - } - } - else { - ProcessResults( vBar[nCurrBar].sBtlPath, vBar[nCurrBar].piInfo, parameters.UIMode) ; - bDone = true ; - nCurrBar ++ ; - } - } - } - else { - if ( vProc[j].Proc.HasExited) { - // se terminato con successo - if ( vProc[j].Proc.ExitCode == 0) { - // salvo il risultato - ProcessResults( vBar[vProc[j].nBar].sBtlPath, vBar[vProc[j].nBar].piInfo, parameters.UIMode) ; - bDone = true ; - vProc[j].nBar = -1 ; - nActProc -- ; - } - // se superato il numero di processi eseguibili in parallelo - else if ( vProc[j].Proc.ExitCode == 1) { - // aggiungo il pezzo in coda - if ( numBars + nShiftBar < numBars + nMaxThread) { - vBar[numBars + nShiftBar] = vBar[vProc[j].nBar] ; - nShiftBar ++ ; - } - // disabilito il processo - vProc[j].bEnable = false ; - vProc[j].nBar = -1 ; - nActProc -- ; - } - // altrimenti (errore generico di esecuzione) - else { - // salvo il risultato - ProcessResults( vBar[vProc[j].nBar].sBtlPath, vBar[vProc[j].nBar].piInfo, parameters.UIMode) ; - bDone = true ; - vProc[j].nBar = -1 ; - nActProc -- ; - } - } - else - vProc[j].Proc.Refresh() ; - } - if ( bDone) { - // Dialog con Progress Bar - dProgress += ( 0.9 / numBars) ; - nDoneBar ++ ; - string sProg = ( dProgress * 100 ).ToString("F1", CultureInfo.InvariantCulture) ; - callback.Progress((float)dProgress, - " Progress: " + sProg + "%" + "\n" + - " Count: " + nDoneBar + " / " + numBars, - ref bCancel); - if ( bCancel ) { - callback.Done( parameters) ; // fine - return ; - } - } - Thread.Sleep( 1) ; - } - // Verifico che i processi non siano andati tutti in errore - bool bAllKO = true ; - for ( int j = 0 ; j < nMaxThread ; ++ j) { - if ( vProc[j].bEnable) - bAllKO = false ; - } - if ( bAllKO) { - MessageBox.Show( "Execution error (all processes are disabled)") ; - break ; - } - Thread.Sleep( 10) ; - } - - callback.Progress( 1, "End", ref bCancel) ; - Thread.Sleep( 300) ; - - callback.Done( parameters) ; // fine - } - - //------------------------------------------------------------------------------------------------------------- - public void Abort() - { - //non implementata al momento - } - - //------------------------------------------------------------------------------------------------------------- - private static void ProcessResults( string BtlPath, PatternInfo pattInfo, InOutParameters.UIModes UIMode) - { - if ( UIMode == InOutParameters.UIModes.SHOWUI || UIMode == InOutParameters.UIModes.SIMULAZIONE) - return ; - bool bErrors = false ; - int nLastErr = 0 ; - string sLastMsg = "" ; - int nCurrCutId = 0 ; - Dictionary dctErr = new Dictionary() ; - Dictionary dctRot = new Dictionary() ; - int nTotTime = 0 ; - if ( File.Exists( Path.ChangeExtension( BtlPath, ".txt"))) { - int nErr = 0 ; - string sMsg = "" ; - double dRot = 0 ; - int cutId = 0 ; - int taskId = 0 ; - string[] lines = System.IO.File.ReadAllLines( Path.ChangeExtension( BtlPath, ".txt")) ; - foreach ( string line in lines) { - if ( line.StartsWith( "ERR=")) { - int? nVal = GetVal(line, "ERR") ; - nErr = ( nVal != null ? nVal.Value : 0) ; - sMsg = "" ; - cutId = 0 ; - taskId = 0 ; - } - else if ( line.StartsWith( "ROT=")) { - int? nVal = GetVal( line, "ROT") ; - int nRot = ( nVal != null ? nVal.Value : 0) ; - dRot = (( 4 - nRot) % 4) * 90 ; - } - else if ( line.StartsWith( "CUTID=")) { - int? nVal = GetVal( line, "CUTID") ; - cutId = ( nVal != null ? nVal.Value : 0) ; - if ( cutId != nCurrCutId) { - nCurrCutId = cutId ; - dctErr.Clear() ; - dctRot.Clear() ; - } - } - else if ( line.StartsWith( "TASKID=")) { - int? nVal = GetVal( line, "TASKID") ; - taskId = ( nVal != null ? nVal.Value : 0) ; - PatternInfo.Results resExe = PatternInfo.Results.OK ; - if ( nErr == 22) { - resExe = PatternInfo.Results.COLLISION ; - bErrors = true ; - // se non assegnata a feature la dichiaro globale - if ( cutId == 0 || taskId == 0) { - nLastErr = nErr ; - sLastMsg = sMsg ; - } - } - else if ( nErr > 0) { - resExe = PatternInfo.Results.WARNING ; - bErrors = true ; - // se non assegnata a feature la dichiaro globale - if ( cutId == 0 || taskId == 0) { - nLastErr = nErr ; - sLastMsg = sMsg ; - } - } - // gestione errore per feature identificata - if ( taskId != 0) { - // verifiche per feature con più parti - if ( dctErr.TryGetValue( taskId, out PatternInfo.Results resCurrExe)) { - if ( resExe > resCurrExe) { - dctErr[taskId] = resExe ; - pattInfo.SetTaskState( cutId, taskId, resExe, sMsg) ; - } - } - else { - dctErr[taskId] = resExe ; - pattInfo.SetTaskState( cutId, taskId, resExe, sMsg) ; - } - } - // altrimenti per feature generica - else { - pattInfo.SetTaskState( cutId, taskId, resExe, sMsg) ; - } - // gestione rotazione per feature identificata - if ( taskId != 0) { - // verifiche per feature con più parti - if ( dctRot.TryGetValue( taskId, out double dCurrRot)) { - if ( Math.Abs( dRot) > 1) { - if ( Math.Abs( dCurrRot) < 1) - dctRot[taskId] = dRot ; - } - else { - dRot = dCurrRot ; - } - } - else { - dctRot.Add( taskId, dRot) ; - } - } - // imposto la rotazione - if ( pattInfo.IsFromProject) - pattInfo.SetProcessInfoChosen( cutId, taskId, dRot, 0, false) ; - else - pattInfo.SetTaskInfoChosen( cutId, taskId, dRot, 0, false) ; - } - else if ( line.StartsWith( "TIME=")) { - int? nVal = GetVal( line, "TIME") ; - nTotTime = ( nVal != null ? nVal.Value : 0) ; - } - else if ( ! string.IsNullOrWhiteSpace( line) && line != "---") - sMsg = line ; - } - } - else { - bErrors = true ; - nLastErr = 25 ; - sLastMsg = "Execution Error" ; - } - pattInfo.IsDone = true ; - if ( ! bErrors) { - pattInfo.Result = PatternInfo.Results.OK ; - pattInfo.DetailResult = PatternInfo.DetailResults.MEMORY ; - } - else { - // Sezione oltre i limiti - if ( nLastErr == 17) { - pattInfo.Result = PatternInfo.Results.ERROR ; - pattInfo.DetailResult = PatternInfo.DetailResults.ALL_WARNING ; - pattInfo.Message = sLastMsg ; - } - // Errore nel calcolo lavorazione o movimento carrelli - else if ( nLastErr == 19) { - pattInfo.Result = PatternInfo.Results.ERROR ; - pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR ; - pattInfo.Message = sLastMsg ; - } - // Collisione non assegnata ad una feature - else if ( nLastErr == 22) { - pattInfo.Result = PatternInfo.Results.ERROR ; - pattInfo.DetailResult = PatternInfo.DetailResults.ALL_COLLISION ; - pattInfo.Message = sLastMsg ; - } - // Extra corsa assi - else if ( nLastErr == 23) { - pattInfo.Result = PatternInfo.Results.ERROR ; - pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR ; - pattInfo.Message = sLastMsg ; - } - // Carri che scivolano sulla trave - else if ( nLastErr == 24) { - pattInfo.Result = PatternInfo.Results.ERROR ; - pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR ; - pattInfo.Message = sLastMsg ; - } - // Errore generico - else if ( nLastErr == 25) { - pattInfo.Result = PatternInfo.Results.ERROR ; - pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR ; - pattInfo.Message = sLastMsg ; - } - // Altro - else { - pattInfo.Result = PatternInfo.Results.ERROR ; - pattInfo.DetailResult = PatternInfo.DetailResults.MEMORY ; - } - } - pattInfo.EstimatedTime = nTotTime ; - - // Lettura OutputFilename e scrittura nel parametro stringa Iso (caso UIModes.HIDDEN) - if ( ! bErrors && - ( UIMode == InOutParameters.UIModes.HIDDEN || UIMode == InOutParameters.UIModes.CLOUD)) { - - string CncPath = Path.ChangeExtension( BtlPath, ".cnc") ; - if ( File.Exists( CncPath)) { - string lines = System.IO.File.ReadAllText(CncPath) ; - pattInfo.Iso = lines ; - pattInfo.Result = PatternInfo.Results.OK ; - pattInfo.DetailResult = PatternInfo.DetailResults.ALL_OK ; - } - else { - pattInfo.Iso = "" ; - pattInfo.Result = PatternInfo.Results.ERROR ; - pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR ; - } - } - } - - //------------------------------------------------------------------------------------------------------------- - // Il seguente metodo prende i record visualizzati in ds (Caso: Produzione) e li carica in un oggetto BTL - public static void GetListaTasks( BTL btlObject) - { - DataTable dTab = _ds.Tables[0] ; - Int32 listaTasksCount = dTab.Rows.Count ; - if ( listaTasksCount == 0) - return ; - - DataRow dRow0 = dTab.Rows[0] ; - btlObject.projectNumber = dRow0["projectId"].ToString() ; - btlObject.barLength = GetBarLengthP( (int)dRow0["patternId"], (int)dRow0["productionId"]).ToString( "F3", CultureInfo.InvariantCulture) ; - btlObject.barLoad90 = GetBarLoad90P( (int)dRow0["patternId"], (int)dRow0["productionId"]).ToString( CultureInfo.InvariantCulture) ; - btlObject.panelLength = GetBarLengthP( (int)dRow0["patternId"], (int)dRow0["productionId"]).ToString( "F3", CultureInfo.InvariantCulture) ; - btlObject.panelWidth = GetBarWidthP( (int)dRow0["patternId"], (int)dRow0["productionId"]).ToString( "F3", CultureInfo.InvariantCulture) ; - btlObject.productionId = (int)dRow0["productionId"] ; - btlObject.patternId = (int)dRow0["patternId"] ; - btlObject.parts = new List() ; - - List ListaCutParts = GetListaCutIdP() ; - - for ( int c = 0 ; c < ListaCutParts.Count ; c++) { - - BTL.Part readPart = new BTL.Part() ; - - bool bFirst = true ; - for ( int f = 0; f < listaTasksCount; f++) { - - DataRow dRowF = dTab.Rows[f] ; - if ( (int)dRowF["cutId"] != ListaCutParts[c]) - continue ; - - if ( bFirst) { - readPart.singleMemberNumber = GetElementSN( (int)dRowF["elementId"], (int)dRowF["projectId"]) ; - readPart.count = "1" ; - readPart.length = dRowF["length"].ToString() ; - readPart.height = dRowF["height"].ToString() ; - readPart.width = dRowF["width"].ToString() ; - readPart.x = (double)dRowF["x"] ; - readPart.z = (double)dRowF["z"] ; - readPart.inverted = (double)dRowF["inverted"] ; - readPart.rotated = (double)dRowF["rotated"] ; - readPart.cutId = (int)dRowF["cutId"] ; - bFirst = false ; - readPart.features = new List() ; - } - - if ( string.IsNullOrEmpty( dRowF["taskId"].ToString())) - continue ; - - BTL.Feature readFeature = new BTL.Feature() { - taskId = dRowF["taskId"].ToString(), - processKey = dRowF["group"].ToString() + - "-" + dRowF["key"].ToString().Substring( 1, 3) + - "-" + dRowF["face"].ToString(), - designation = dRowF["des"].ToString(), - processIdent = dRowF["processIdent"].ToString(), - sag1 = dRowF["sag1"].ToString(), - text = dRowF["text"].ToString(), - process = ( Convert.ToInt16( dRowF["enabled"]) == 1) ? "YES" : "NO", - processParameters = new List( 46) { - dRowF["p01"].ToString(), - dRowF["p02"].ToString(), - dRowF["p03"].ToString(), - dRowF["p04"].ToString(), - dRowF["p05"].ToString(), - dRowF["p06"].ToString(), - dRowF["p07"].ToString(), - dRowF["p08"].ToString(), - dRowF["p09"].ToString(), - dRowF["p10"].ToString(), - dRowF["p11"].ToString(), - dRowF["p12"].ToString(), - dRowF["p13"].ToString(), - dRowF["p14"].ToString(), - dRowF["p15"].ToString(), - dRowF["p16"].ToString(), - dRowF["p17"].ToString(), - dRowF["p18"].ToString(), - dRowF["p19"].ToString(), - dRowF["p20"].ToString(), - dRowF["p21"].ToString(), - dRowF["p22"].ToString(), - dRowF["p23"].ToString(), - dRowF["p24"].ToString(), - dRowF["p25"].ToString(), - dRowF["p26"].ToString(), - dRowF["q01"].ToString(), - dRowF["q02"].ToString(), - dRowF["q03"].ToString(), - dRowF["q04"].ToString(), - dRowF["q05"].ToString(), - dRowF["q06"].ToString(), - dRowF["q07"].ToString(), - dRowF["q08"].ToString(), - dRowF["q09"].ToString(), - dRowF["q10"].ToString(), - dRowF["q11"].ToString(), - dRowF["q12"].ToString(), - dRowF["q13"].ToString(), - dRowF["q14"].ToString(), - dRowF["q15"].ToString(), - dRowF["q16"].ToString(), - dRowF["q17"].ToString(), - dRowF["q18"].ToString(), - dRowF["q19"].ToString(), - dRowF["q20"].ToString() - }, - processReference = new List( 9) { - dRowF["ox"].ToString(), - dRowF["oy"].ToString(), - dRowF["oz"].ToString(), - dRowF["xx"].ToString(), - dRowF["xy"].ToString(), - dRowF["xz"].ToString(), - dRowF["yx"].ToString(), - dRowF["yy"].ToString(), - dRowF["yz"].ToString() - }, - } ; - readPart.features.Add( readFeature) ; - } - btlObject.parts.Add( readPart) ; - } - // L'ordinamento delle Part in un oggetto BTL avviene col confronto del parametro x, estratto dalla tabella vw_Cut - btlObject.parts.Sort( (p, q) => p.x.CompareTo( q.x)) ; - } - - //------------------------------------------------------------------------------------------------------------- - private static int? GetVal( string sText, string sKey) - { - string[] sParts = sText.Split( new Char[] { '=' }) ; - if ( string.Compare( sParts[0], sKey) != 0) - return null ; - if ( ! int.TryParse( sParts[1], out int nVal)) - return null ; - else - return nVal ; - } - - //------------------------------------------------------------------------------------------------------------- - // Il seguente metodo prende i record visualizzati in ds (Caso: Ordine) e li carica in un oggetto BTL - public static void GetListaProcesses( BTL btlObject) - { - DataTable dTab = _ds.Tables[0] ; - int listaProcessesCount = dTab.Rows.Count ; - if ( listaProcessesCount == 0) { - btlObject.parts = null ; - return ; - } - - DataRow dRow0 = dTab.Rows[0] ; - btlObject.projectNumber = dRow0["projectId"].ToString() ; - btlObject.barLength = GetBarLengthO( (int)dRow0["elementId"], (int)dRow0["projectId"]).ToString( "F3", CultureInfo.InvariantCulture) ; - btlObject.barLoad90 = "0" ; - btlObject.panelLength = GetPanelLengthO( (int)dRow0["elementId"], (int)dRow0["projectId"]).ToString( "F3", CultureInfo.InvariantCulture) ; - btlObject.panelWidth = GetPanelWidthO( (int)dRow0["elementId"], (int)dRow0["projectId"]).ToString( "F3", CultureInfo.InvariantCulture) ; - btlObject.projectId = (int)dRow0["projectId"] ; - btlObject.elementId = (int)dRow0["elementId"] ; - btlObject.parts = new List() ; - - List ListaCutParts = new List( 1) ; - ListaCutParts.Add( (int)dRow0["elementId"]) ; - - for ( int c = 0 ; c < ListaCutParts.Count ; c++) { - - BTL.Part readPart = new BTL.Part() ; - - bool bFirst = true ; - for ( int f = 0 ; f < listaProcessesCount ; f++) { - - DataRow dRowF = dTab.Rows[f] ; - if ( (int)dRowF["elementId"] != ListaCutParts[c]) - continue ; - - if ( bFirst) { - readPart.singleMemberNumber = GetElementSN( (int)dRow0["elementId"], (int)dRow0["projectId"]) ; - readPart.count = "1" ; - readPart.length = dRowF["length"].ToString() ; - readPart.height = dRowF["height"].ToString() ; - readPart.width = dRowF["width"].ToString() ; - readPart.x = Constants.HeadOverMat ; - readPart.z = Constants.HeadOverMat ; - readPart.inverted = (double)dRowF["inverted"] ; - readPart.rotated = (double)dRowF["rotated"] ; - readPart.elementId = (int)dRowF["elementId"] ; - bFirst = false ; - readPart.features = new List() ; - } - - if ( string.IsNullOrEmpty( dRowF["processId"].ToString())) - continue ; - - BTL.Feature readFeature = new BTL.Feature() { - processId = dRowF["processId"].ToString(), - processKey = dRowF["group"].ToString() + - "-" + dRowF["key"].ToString().Substring( 1, 3) + - "-" + dRowF["face"].ToString(), - designation = dRowF["des"].ToString(), - processIdent = dRowF["processIdent"].ToString(), - sag1 = dRowF["sag1"].ToString(), - text = dRowF["text"].ToString(), - process = ( Convert.ToInt16( dRowF["enabled"]) == 1) ? "YES" : "NO", - processParameters = new List( 46) { - dRowF["p01"].ToString(), - dRowF["p02"].ToString(), - dRowF["p03"].ToString(), - dRowF["p04"].ToString(), - dRowF["p05"].ToString(), - dRowF["p06"].ToString(), - dRowF["p07"].ToString(), - dRowF["p08"].ToString(), - dRowF["p09"].ToString(), - dRowF["p10"].ToString(), - dRowF["p11"].ToString(), - dRowF["p12"].ToString(), - dRowF["p13"].ToString(), - dRowF["p14"].ToString(), - dRowF["p15"].ToString(), - dRowF["p16"].ToString(), - dRowF["p17"].ToString(), - dRowF["p18"].ToString(), - dRowF["p19"].ToString(), - dRowF["p20"].ToString(), - dRowF["p21"].ToString(), - dRowF["p22"].ToString(), - dRowF["p23"].ToString(), - dRowF["p24"].ToString(), - dRowF["p25"].ToString(), - dRowF["p26"].ToString(), - dRowF["q01"].ToString(), - dRowF["q02"].ToString(), - dRowF["q03"].ToString(), - dRowF["q04"].ToString(), - dRowF["q05"].ToString(), - dRowF["q06"].ToString(), - dRowF["q07"].ToString(), - dRowF["q08"].ToString(), - dRowF["q09"].ToString(), - dRowF["q10"].ToString(), - dRowF["q11"].ToString(), - dRowF["q12"].ToString(), - dRowF["q13"].ToString(), - dRowF["q14"].ToString(), - dRowF["q15"].ToString(), - dRowF["q16"].ToString(), - dRowF["q17"].ToString(), - dRowF["q18"].ToString(), - dRowF["q19"].ToString(), - dRowF["q20"].ToString() - }, - processReference = new List( 9) { - dRowF["ox"].ToString(), - dRowF["oy"].ToString(), - dRowF["oz"].ToString(), - dRowF["xx"].ToString(), - dRowF["xy"].ToString(), - dRowF["xz"].ToString(), - dRowF["yx"].ToString(), - dRowF["yy"].ToString(), - dRowF["yz"].ToString() - }, - } ; - readPart.features.Add( readFeature) ; - } - btlObject.parts.Add( readPart) ; - } - // L'ordinamento delle Part in un oggetto BTL avviene col confronto del parametro x, estratto dalla tabella vw_Cut - btlObject.parts.Sort( (p, q) => p.x.CompareTo( q.x)) ; - } - - //------------------------------------------------------------------------------------------------------------- - // Il seguente metodo si connette al DB per estrarre tramite una query i cutId della tabella vw_Cut - // aventi patternId e ProductionId che corrispondono a quelli passati come argomento - private static List GetListaCutIdP() - { - List ListaCutId = new List() ; - - DataTable dTab = _ds.Tables[0] ; - int listaTasksCount = dTab.Rows.Count ; - for ( int f = 0 ; f < listaTasksCount ; f++) { - int nCut = (int) dTab.Rows[f]["cutId"] ; - if ( ! ListaCutId.Contains( nCut)) - ListaCutId.Add( nCut) ; - } - - return ListaCutId ; - } - - //------------------------------------------------------------------------------------------------------------- - // Recupera il singlemembernumber dell'Elemento (colonna "sn") - private static string GetElementSN( int ElementId, int ProjectId) - { - string SN = "000" ; - - string sqlElementSN = "SELECT sn " + - "FROM dbo.vw_Element " + - "WHERE elementId = @firstId " + - "AND projectId = @secondId" ; - - // Connessione al DB ed esecuzione query - using ( SqlConnection cn = new SqlConnection( _SqlConnectionStr)) { - cn.Open() ; - using ( SqlCommand sqlCommand = new SqlCommand( sqlElementSN, cn)) { - sqlCommand.Parameters.Add( "@firstId", SqlDbType.Int) ; - sqlCommand.Parameters.Add( "@secondId", SqlDbType.Int) ; - sqlCommand.Parameters["@firstId"].Value = ElementId ; - sqlCommand.Parameters["@secondId"].Value = ProjectId ; - SqlDataReader reader = sqlCommand.ExecuteReader() ; - while ( reader.Read()) { - SN = Convert.ToString( reader["sn"]) ; - } - } - } - - return SN ; - } - - //------------------------------------------------------------------------------------------------------------- - // Recupera la lunghezza della barra nel caso Produzione (colonna "l") - private static double GetBarLengthP( int patternId, int productionId) - { - double barLength = 0 ; - - string sqlBarLength = "SELECT l " + - "FROM dbo.vw_Pattern " + - "WHERE patternId = @firstId " + - "AND productionId = @secondId" ; - - // Connessione al DB ed esecuzione query - using ( SqlConnection cn = new SqlConnection( _SqlConnectionStr)) { - cn.Open() ; - using ( SqlCommand sqlCommand = new SqlCommand( sqlBarLength, cn)) { - sqlCommand.Parameters.Add( "@firstId", SqlDbType.Int) ; - sqlCommand.Parameters.Add( "@secondId", SqlDbType.Int) ; - sqlCommand.Parameters["@firstId"].Value = patternId ; - sqlCommand.Parameters["@secondId"].Value = productionId ; - SqlDataReader reader = sqlCommand.ExecuteReader() ; - while ( reader.Read()) { - barLength = Convert.ToDouble( reader["l"]) ; - } - } - } - - return barLength ; - } - - //------------------------------------------------------------------------------------------------------------- - // Recupera la larghezza della barra nel caso Produzione (colonna "w") - private static double GetBarWidthP( int patternId, int productionId) - { - double barWidth = 0 ; - - string sqlBarWidth = "SELECT w " + - "FROM dbo.vw_Pattern " + - "WHERE patternId = @firstId " + - "AND productionId = @secondId" ; - - // Connessione al DB ed esecuzione query - using ( SqlConnection cn = new SqlConnection( _SqlConnectionStr)) { - cn.Open() ; - using ( SqlCommand sqlCommand = new SqlCommand( sqlBarWidth, cn)) { - sqlCommand.Parameters.Add( "@firstId", SqlDbType.Int) ; - sqlCommand.Parameters.Add( "@secondId", SqlDbType.Int) ; - sqlCommand.Parameters["@firstId"].Value = patternId ; - sqlCommand.Parameters["@secondId"].Value = productionId ; - SqlDataReader reader = sqlCommand.ExecuteReader() ; - while ( reader.Read()) { - barWidth = Convert.ToDouble( reader["w"]) ; - } - } - } - - return barWidth ; - } - - //------------------------------------------------------------------------------------------------------------- - // Recupera il flag di carico con rotazione di 90° nel caso Produzione (colonna "load90") - private static int GetBarLoad90P( int patternId, int productionId) - { - int nLoad90 = 0 ; - - string sqlBarLength = "SELECT load90 " + - "FROM dbo.vw_Pattern " + - "WHERE patternId = @firstId " + - "AND productionId = @secondId" ; - - // Connessione al DB ed esecuzione query - using ( SqlConnection cn = new SqlConnection( _SqlConnectionStr)) { - cn.Open() ; - using ( SqlCommand sqlCommand = new SqlCommand( sqlBarLength, cn)) { - sqlCommand.Parameters.Add( "@firstId", SqlDbType.Int) ; - sqlCommand.Parameters.Add( "@secondId", SqlDbType.Int) ; - sqlCommand.Parameters["@firstId"].Value = patternId ; - sqlCommand.Parameters["@secondId"].Value = productionId ; - SqlDataReader reader = sqlCommand.ExecuteReader() ; - while ( reader.Read()) { - nLoad90 = Convert.ToInt32( reader["load90"]) ; - } - } - } - - return nLoad90 ; - } - - //------------------------------------------------------------------------------------------------------------- - // Recupera lo stato della barra nel caso Produzione (colonna "state") - private static int GetBarStateP( int patternId, int productionId) - { - int barState = 16 ; - - string sqlBarLength = "SELECT state " + - "FROM dbo.vw_Pattern " + - "WHERE patternId = @firstId " + - "AND productionId = @secondId" ; - - // Connessione al DB ed esecuzione query - using ( SqlConnection cn = new SqlConnection( _SqlConnectionStr)) { - cn.Open() ; - using ( SqlCommand sqlCommand = new SqlCommand( sqlBarLength, cn)) { - sqlCommand.Parameters.Add( "@firstId", SqlDbType.Int) ; - sqlCommand.Parameters.Add( "@secondId", SqlDbType.Int) ; - sqlCommand.Parameters["@firstId"].Value = patternId ; - sqlCommand.Parameters["@secondId"].Value = productionId ; - SqlDataReader reader = sqlCommand.ExecuteReader() ; - while ( reader.Read()) { - barState = Convert.ToInt32( reader["state"]) ; - } - } - } - - return barState ; - } - - //------------------------------------------------------------------------------------------------------------- - // Recupera la lunghezza della barra nel caso Ordine (colonna "length", ovvero la lunghezza della singola trave) - // a cui aggiungiamo un valore fisso (es. 2000) - private static double GetBarLengthO( int elementId, int projectId) - { - double barLength = 0 ; - - DataTable dTab = _ds.Tables[0] ; - int listaProcessesCount = dTab.Rows.Count ; - if ( listaProcessesCount > 0) { - double beamLength = Convert.ToDouble( dTab.Rows[0]["length"]) ; - if ( beamLength < Constants.BarMaxLenForAdd) - barLength = beamLength + Constants.BarAddLen ; - else - barLength = beamLength + 2 * Constants.HeadOverMat ; - } - - return barLength ; - } - - //------------------------------------------------------------------------------------------------------------- - // Recupera la lunghezza del pannello nel caso Ordine (colonna "length", ovvero la lunghezza della singola parete) - // a cui aggiungiamo un valore fisso (es. 200) - private static double GetPanelLengthO( int elementId, int projectId) - { - double panelLength = 0 ; - - DataTable dTab = _ds.Tables[0] ; - int listaProcessesCount = dTab.Rows.Count ; - if ( listaProcessesCount > 0) { - double wallLength = Convert.ToDouble( dTab.Rows[0]["length"]) ; - panelLength = wallLength + 2 * Constants.PanelOverMat ; - } - - return panelLength ; - } - - //------------------------------------------------------------------------------------------------------------- - // Recupera la lunghezza del pannello nel caso Ordine (colonna "width", ovvero la larghezza della singola parete) - // a cui aggiungiamo un valore fisso (es. 200) - private static double GetPanelWidthO( int elementId, int projectId) - { - double panelWidth = 0 ; - - DataTable dTab = _ds.Tables[0] ; - int listaProcessesCount = dTab.Rows.Count ; - if ( listaProcessesCount > 0) { - double wallWidth = Convert.ToDouble( dTab.Rows[0]["width"]) ; - panelWidth = wallWidth + 2 * Constants.PanelOverMat ; - } - - return panelWidth ; - } - - //------------------------------------------------------------------------------------------------------------- - // Restituisce la path di esecuzione di EgtCam5 - private static String GetExePath( InOutParameters parameters) - { - return parameters.Read( "EGALTECH", "PATH_EXE", "") ; - } - - //------------------------------------------------------------------------------------------------------------- - // Restituisce il direttorio per i file con i dati macchina - private static String GetDataDir( InOutParameters parameters) - { - String DataDir = parameters.Read( "EGALTECH", "DIR_DATA", "") ; - // Se la directory non esiste viene creata - DirectoryInfo di = new DirectoryInfo( DataDir) ; - if ( ! di.Exists) - di.Create() ; - return DataDir ; - } - - //------------------------------------------------------------------------------------------------------------- - // Restituisce la path completa per il file BTL - private static String GetBtlPath( String DataDir, PatternInfo pattInfo) - { - String BtlDir, BtlName ; - // Se progetto - if ( pattInfo.IsFromProject) { - BtlDir = Path.Combine( DataDir, "Projs", pattInfo.ProjectId.ToString( "D4")) ; - BtlName = "Part_" + pattInfo.ProjectId.ToString() + "_" + pattInfo.ElementId.ToString() + ".btl" ; - } - // altrimenti produzione - else { - BtlDir = Path.Combine( DataDir, "Prods", pattInfo.ProductionId.ToString( "D4")) ; - BtlName = "Bar_" + pattInfo.ProductionId.ToString() + "_" + pattInfo.PatternId.ToString() + ".btl" ; - } - // Se la directory non esiste viene creata - DirectoryInfo di = new DirectoryInfo( BtlDir) ; - if ( ! di.Exists) - di.Create() ; - // restituisco la path completa - return Path.Combine( BtlDir, BtlName) ; - } - - //------------------------------------------------------------------------------------------------------------- - // Restituisce il massimo numero di istanze di EgtCAM5 eseguibili contemporaneamente - private static int GetMaxInstances( InOutParameters parameters) - { - String sMaxInst = parameters.Read( "EGALTECH", "MaxInstances", "1") ; - if ( ! int.TryParse( sMaxInst, out int nVal)) - return 1 ; - else - return Math.Max( nVal, 1) ; - } - - //------------------------------------------------------------------------------------------------------------- - // Visualizzazione finestra gestione DB utensili - public bool ShowTools( InOutParameters parameters) - { - // Recupero dati - string ExePath = GetExePath( parameters) ; - string DataDir = GetDataDir( parameters) ; - string BtlPath = Path.Combine( DataDir, "QQQ.btl") ; - // Esecuzione di EgtCAM5 con parametri path BTL, nome macchina e modo - Process process = new Process() ; - process.StartInfo.FileName = ExePath ; - process.StartInfo.Arguments = "\"" + BtlPath + "\" " + parameters.MachineName + " 11" ; - process.StartInfo.UseShellExecute = false ; - process.Start() ; - // Attendo il termine del processo - while ( ! process.HasExited) { - process.Refresh() ; - Thread.Sleep( 50) ; - } - return true ; - } - - //------------------------------------------------------------------------------------------------------------- - // Visualizzazione finestra gestione DB lavorazioni - public bool ShowJobs( InOutParameters parameters) - { - // Recupero dati - string ExePath = GetExePath( parameters) ; - string DataDir = GetDataDir( parameters) ; - string BtlPath = Path.Combine( DataDir, "QQQ.btl") ; - // Esecuzione di EgtCAM5 con parametri path BTL, nome macchina e modo - Process process = new Process() ; - process.StartInfo.FileName = ExePath ; - process.StartInfo.Arguments = "\"" + BtlPath + "\" " + parameters.MachineName + " 12" ; - process.StartInfo.UseShellExecute = false ; - process.Start() ; - // Attendo il termine del processo - while ( ! process.HasExited) { - process.Refresh() ; - Thread.Sleep( 50) ; - } - return true ; - } - - //------------------------------------------------------------------------------------------------------------- - // Aggiornamento dati macchina - public bool UpdateMachine( InOutParameters parameters) - { - GetMachineParams( parameters) ; - - return true ; - } - - //------------------------------------------------------------------------------------------------------------- - // Dati utensili e macchina - //------------------------------------------------------------------------------------------------------------- - // Import della funzione di sistema per la scrittura su file INI - [DllImport("kernel32", CharSet = CharSet.Unicode)] - static extern long WritePrivateProfileString( string Section, string Key, string Value, string FilePath) ; - - //------------------------------------------------------------------------------------------------------------- - // Scrive il file Essetre-[MachineName].data che riporta i parametri macchina del DB - private static void GetMachineParams( InOutParameters parameters) - { - // Direttorio di scrittura del file - String DataDir = GetDataDir( parameters) ; - - // Path del file di dati e sua cancellazione se già esiste - string DataName = "Essetre-" + parameters.MachineName + ".data" ; - string DataPath = Path.Combine( DataDir, DataName) ; - if ( File.Exists( DataPath)) - File.Delete( DataPath) ; - - // Preparazione interrogazione per Offsets del DB - _SqlConnectionStr = parameters.ConnectionString ; - DataSet dsOffsets = new DataSet() ; - - string sqlOffsets = "SELECT [group], [key], [value] " + - "FROM [ESSETRE].[dbo].[vw_MachineParam] " + - "WHERE [group] = 'OFFSETS' AND configurationId = @ConfigId" ; - - // Connessione al DB ed esecuzione query - using ( SqlConnection cn = new SqlConnection(_SqlConnectionStr)) { - cn.Open() ; - using ( SqlCommand cmd = new SqlCommand(sqlOffsets, cn)) { - cmd.Parameters.Add( "@ConfigId", SqlDbType.Int) ; - cmd.Parameters["@ConfigId"].Value = parameters.ConfigurationId ; - var dataAdapter = new SqlDataAdapter( cmd) ; - // Lettura DB e riempimento DataSet - dsOffsets.Clear() ; - dataAdapter.Fill(dsOffsets) ; - } - } - - // Preparazione interrogazione per Trave del DB - _SqlConnectionStr = parameters.ConnectionString ; - DataSet dsTrave = new DataSet() ; - - string sqlTrave = "SELECT [group], [key], [value] " + - "FROM [ESSETRE].[dbo].[vw_MachineParam] " + - "WHERE [group] = 'TRAVE' AND configurationId = @ConfigId" ; - - // Connessione al DB ed esecuzione query - using ( SqlConnection cn = new SqlConnection(_SqlConnectionStr)) { - cn.Open() ; - using ( SqlCommand cmd = new SqlCommand( sqlTrave, cn)) { - cmd.Parameters.Add( "@ConfigId", SqlDbType.Int) ; - cmd.Parameters["@ConfigId"].Value = parameters.ConfigurationId ; - var dataAdapter = new SqlDataAdapter( cmd) ; - // Lettura DB e riempimento DataSet - dsTrave.Clear() ; - dataAdapter.Fill( dsTrave) ; - } - } - - // Preparazione interrogazione per Dati Utente del DB - _SqlConnectionStr = parameters.ConnectionString; - DataSet dsUser = new DataSet(); - - string sqlUser = "SELECT [group], [key], [value] " + - "FROM [ESSETRE].[dbo].[vw_ConfigurationParam] " + - "WHERE [group] <> 'TEXTS' AND [group] <> 'PARAMS' AND configurationId = @ConfigId"; - - // Connessione al DB ed esecuzione query - using (SqlConnection cn = new SqlConnection(_SqlConnectionStr)) - { - cn.Open(); - using (SqlCommand cmd = new SqlCommand(sqlUser, cn)) - { - cmd.Parameters.Add("@ConfigId", SqlDbType.Int); - cmd.Parameters["@ConfigId"].Value = parameters.ConfigurationId; - var dataAdapter = new SqlDataAdapter(cmd); - // Lettura DB e riempimento DataSet - dsUser.Clear(); - dataAdapter.Fill(dsUser); - } - } - - // Apro file - using ( var tw = new StreamWriter( DataPath, false)) { - - // Scrittura intestazione - tw.WriteLine( "-- " + DataPath) ; - tw.WriteLine( "") ; - - // Scrittura dei dati di Offsets - tw.WriteLine( "local Offsets = {") ; - foreach ( DataTable table in dsOffsets.Tables) { - foreach ( DataRow row in table.Rows) { - String Key = row["key"].ToString() ; - String Value = row["value"].ToString() ; - tw.WriteLine( " " + Key + "=" + Value + ",") ; - } - } - tw.WriteLine( " Zzz=1") ; - tw.WriteLine( "}") ; - tw.WriteLine( "") ; - - // Scrittura dei dati di Trave - tw.WriteLine( "local Trave = {") ; - foreach ( DataTable table in dsTrave.Tables) { - foreach ( DataRow row in table.Rows) { - String Key = row["key"].ToString() ; - String Value = row["value"].ToString() ; - tw.WriteLine( " " + Key + "=" + Value + ",") ; - } - } - tw.WriteLine( " Zzz=1") ; - tw.WriteLine( "}") ; - tw.WriteLine( "") ; - - // Scrittura dei dati di Utente - tw.WriteLine("local User = {"); - foreach (DataTable table in dsUser.Tables) - { - foreach (DataRow row in table.Rows) - { - String Group = row["group"].ToString(); - String Key = row["key"].ToString(); - String Value = row["value"].ToString(); - tw.WriteLine(" " + Group + "_" + Key + "=" + Value + ","); - } - } - tw.WriteLine(" Zzz=1"); - tw.WriteLine("}"); - tw.WriteLine(""); - - // Scrittura tabella da restituire - tw.WriteLine( "local Machine = { Offsets=Offsets, Trave=Trave, User=User}") ; - - tw.WriteLine( "return Machine") ; - } - } - - //------------------------------------------------------------------------------------------------------------- - // Indica direttori e file per backup - public void CollectFile( InOutParameters parameters, FileCollector collector) - { - // Direttori notevoli - String sRoot = parameters.Read( "EGALTECH", "DIR_EGT", "C:\\TechnoEssetre7\\EgalTech") ; - String sBeamDir = "EgtCAM5\\Beam" ; - String sMachDir = "EgtCAM5\\Machines\\Essetre-" + parameters.MachineName ; - // Impostazione - collector.SetRoot(sRoot) ; - collector.AddDirectory(Path.Combine(sRoot, sBeamDir)) ; - collector.AddDirectory(Path.Combine(sRoot, sMachDir)) ; - } - - } -} diff --git a/EgtBEAMWALL.ViewerOptimizer/Integration/Original.vb b/EgtBEAMWALL.ViewerOptimizer/Integration/Original.vb deleted file mode 100644 index b25d3637..00000000 --- a/EgtBEAMWALL.ViewerOptimizer/Integration/Original.vb +++ /dev/null @@ -1,1211 +0,0 @@ -Imports System -Imports System.Windows.Forms -Imports System.Collections.Generic -Imports System.Data -Imports System.Data.SqlClient -Imports System.Diagnostics -Imports System.IO -Imports System.Linq -Imports System.Runtime.InteropServices -Imports System.Text -Imports System.Threading -Imports System.Threading.Tasks -Imports System.Globalization -Imports EgtUILib -Imports EgtWPFLib5 - -Public Class CalcIntegration - - Private _thread As System.Threading.Thread - Private Shared _ds As DataSet = New DataSet() - Private Shared _SqlConnectionStr As String = "" - - Public Enum CmdType As Integer - GENERATE = 0 - MODIFY = 1 - SIMULATE = 2 - CHECK = 3 - CHECKGEN = 4 - POINT_CLOUD = 5 - RAWPART = 6 - End Enum - - Public Class Bar - 'Public piInfo As PatternInfo - Public nBarState As Integer - Public nBarId As Integer - Public sBarPath As String - Public bBarOk As Boolean - Public nCmdType As Integer - Public nBarType As ProjectType - End Class - - Private Structure MyProc - Public bEnable As Boolean - Public Proc As Process - Public nBar As Integer - End Structure - - Public Sub New() - End Sub - - Public Sub Run(vBar As Bar(), sProjDirPath As String, callback As Action(Of Double, String, Boolean)) 'ByVal parameters As InOutParameters, ByVal callback As ICallBack) - _thread = New Thread(Sub() - DoJob(vBar, sProjDirPath, callback) - End Sub) ',parameters, callback)) - _thread.Start() - End Sub - - 'Private Delegate Sub dDoJob(ByVal parameters As InOutParameters, ByVal callback As ICallBack) - - Private Shared Function CreateNewProjectFromPart(nPartId As Integer, sProjDirPath As String) As String - ' assegno Id a CutId per calcoli - EgtSetInfo(nPartId, "CUTID", nPartId) - ' assegno TASKID alla feature per calcoli - Dim nProcessingId As Integer = EgtGetFirstNameInGroup(nPartId, PROCESSINGS) - Dim nFeatureId As Integer = EgtGetFirstInGroup(nProcessingId) - While nFeatureId <> GDB_ID.NULL - ' verifico che sia una feature - Dim nGRP As Integer - If EgtGetInfo(nFeatureId, BTL_FTR_GRP, nGRP) Then - ' assegno TASKID alla feature per calcoli - EgtSetInfo(nFeatureId, "TASKID", nFeatureId) - End If - nFeatureId = EgtGetNext(nFeatureId) - End While - - ' recupero visibilita' pezzo e lo imposto a visibile - Dim nPartMode As Integer - EgtGetMode(nPartId, nPartMode) - EgtSetMode(nPartId, GDB_MD.STD) - - ' salvo pezzo nel suo progetto - Dim bOk As Boolean = False - Dim nPDN As Integer = 0 - EgtGetInfo(nPartId, BTL_PRT_PDN, nPDN) - Dim sPartFilePath As String = sProjDirPath & "/" & nPDN & ".bwe" - bOk = EgtSaveObjToFile(nPartId, sPartFilePath, NGE.BIN) - - 'ripristino visibilita' pezzo - EgtSetMode(nPartId, nPartMode) - Return If(bOk, sPartFilePath, String.Empty) - End Function - - Private Shared Function CreateNewProjectFromMachGroup(nMachGroupId As Integer, sProjDirPath As String) As String - Dim sMachGroupFilePath As String = sProjDirPath & "\" & nMachGroupId & ".bwe" - ' salvo gruppo di lavorazione nel suo progetto - If EgtSaveObjToFile(nMachGroupId, sMachGroupFilePath, NGE.BIN) Then - Return sMachGroupFilePath - End If - Return String.Empty - End Function - - Private Shared Sub DoJob(vBar As Bar(), sProjDirPath As String, callback As Action(Of Double, String, Boolean)) ', parameters As InOutParameters, callback As ICallBack) - Dim bCancel As Boolean = False - callback(0, "Init", bCancel) - - ' creo progetti a seconda del tipo - For Each Bar In vBar - If Bar.nBarType = ProjectType.PROJ Then - Bar.sBarPath = CreateNewProjectFromPart(Bar.nBarId, sProjDirPath) - ElseIf Bar.nBarType = ProjectType.PROD Then - Bar.sBarPath = CreateNewProjectFromMachGroup(Bar.nBarId, sProjDirPath) - End If - Next - - callback(0.1, "", bCancel) - - '_SqlConnectionStr = parameters.ConnectionString - Dim ExePath As String = String.Empty - GetMainPrivateProfileString(S_BEAM, K_CALCPATH, "", ExePath) - 'Dim DataDir As String = GetDataDir(parameters) - ' Numero di barre - Dim numBars As Integer = vBar.Count - If numBars = 0 Then Return - '' Se modalità Cloud, allora conta solo la prima barra - 'Dim bCloud As Boolean = (parameters.UIMode = InOutParameters.UIModes.CLOUD) - 'If bCloud Then numBars = 1 - - ' Numero di core logici da utilizzare (minimo tra presenti sul PC e imposti da INI) - Dim nMaxThread As Integer = Math.Min(Environment.ProcessorCount, Map.refMainWindowVM.MainWindowM.GetMaxInstances()) - - ' Frazione di avanzamento del lavoro (in pu) - Dim dProgress As Double = 0 - '' Genero i Btl di tutte le barre - 'Dim vBar As Bar() = New Bar(numBars + nMaxThread - 1) {} - - 'For i As Integer = 0 To numBars - 1 - ' Dim pattInfo As PatternInfo = parameters.Patterns(i) - ' Dim btlObject As BTL = New BTL() - ' ' Se il parametro IsFromProject è TRUE viene eseguita la query sulle tabelle Project, - ' ' se invece è FALSE viene eseguita la query sulle tabelle Production - - ' Dim sql As String = "" - - ' If pattInfo.IsFromProject Then - ' sql = "SELECT E.projectId, " & "E.elementId, 0 cutId, processId, info1, info2, enabled, level, " & "inTools, outTools, isChecked, P.done, isoType, ax, ay, az, P.x, P.y, P.z, " & "P.flagDeleted, P.[group], [key], face, edge, des, " & "p01, p02, p03, p04, p05, p06, p07, p08, p09, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, " & "q01, q02, q03, q04, q05, q06, q07, q08, q09, q10, q11, q12, q13, q14, q15, q16, q17, q18, q19, q20, " & "ox, oy, oz, xx, xy, xz, yx, yy, yz, " & "priority, processIdent, processingQuality, sag1, text, E.projectId, E.elementId, P.processId, 0 cutStart, 0 cutEnd, " & "E.inverted, E.rotated, 0 doneTime, 0 startAngle, 0 endAngle, -1 referenceCutId, E.length, E.width, E.height " & "FROM dbo.vw_Process AS P " & "RIGHT OUTER JOIN dbo.vw_Element AS E " & "ON P.projectId=E.projectId AND P.elementId=E.elementId " & "WHERE E.projectId = @firstId AND E.elementId = @secondId" - ' Else - ' sql = "SELECT vw_Cut.productionId, " & "vw_Cut.patternId, vw_Cut.cutId, taskId, info1, info2, enabled, level, " & "inTools, outTools, isChecked, vw_Task.done, isoType, ax, ay, az, vw_Cut.x, vw_Cut.y, vw_Cut.z, " & "vw_Task.flagDeleted, [group], [key], face, edge, des, " & "p01, p02, p03, p04, p05, p06, p07, p08, p09, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, " & "q01, q02, q03, q04, q05, q06, q07, q08, q09, q10, q11, q12, q13, q14, q15, q16, q17, q18, q19, q20, " & "ox, oy, oz, xx, xy, xz, yx, yy, yz, " & "priority, processIdent, processingQuality, sag1, text, vw_Cut.projectId, vw_Cut.elementId, cutStart, cutEnd, " & "inverted, rotated, doneTime, startAngle, endAngle, referenceCutId, length, width, height " & "FROM dbo.vw_Task " & "RIGHT OUTER JOIN dbo.vw_Cut " & "ON (vw_Task.cutId = vw_Cut.cutId AND vw_Task.patternId = vw_Cut.patternId AND vw_Task.productionId = vw_Cut.productionId) " & "WHERE vw_Cut.productionId = @firstId AND vw_Cut.patternId = @secondId" - ' End If - - ' ' Connessione al DB ed esecuzione query - ' Using cn As SqlConnection = New SqlConnection(_SqlConnectionStr) - ' cn.Open() - - ' Using cmd As SqlCommand = New SqlCommand(sql, cn) - ' cmd.Parameters.Add("@firstId", SqlDbType.Int) - ' cmd.Parameters.Add("@secondId", SqlDbType.Int) - - ' If pattInfo.IsFromProject Then - ' cmd.Parameters("@firstId").Value = pattInfo.ProjectId - ' cmd.Parameters("@secondId").Value = pattInfo.ElementId - ' Else - ' cmd.Parameters("@firstId").Value = pattInfo.ProductionId - ' cmd.Parameters("@secondId").Value = pattInfo.PatternId - ' End If - - ' Dim dataAdapter = New SqlDataAdapter(cmd) - ' ' Lettura DB e riempimento DataSet - ' _ds.Clear() - ' dataAdapter.Fill(_ds) - ' End Using - ' End Using - - ' ' Verifica parametro isFromProject nel caso Ordine viene ottenuta la lista dei Process, - ' ' nel caso Produzione viene ottenuta la lista dei Task - ' If pattInfo.IsFromProject Then - ' GetListaProcesses(btlObject) - ' Else - ' GetListaTasks(btlObject) - ' End If - - ' ' Recupero lo stato della barra - ' Dim nBarState As Integer = 0 - ' If Not pattInfo.IsFromProject Then nBarState = GetBarStateP(btlObject.patternId, btlObject.productionId) - ' ' Dialog con Progress Bar - ' dProgress += 0.1 / numBars - ' Dim sProg As String = (dProgress * 100).ToString("F1", CultureInfo.InvariantCulture) - ' callback.Progress(CSng(dProgress), " Progress: " & sProg & "%" & vbLf, bCancel) - - ' If bCancel Then - ' callback.Done(parameters) - ' Return - ' End If - - ' ' Scrittura del file BTL - ' ' Path completa del nome del file da salvare - ' Dim BtlPath As String = GetBtlPath(DataDir, pattInfo) - ' Dim BtlOk As Boolean = btlObject.WriteIntoFile(BtlPath, pattInfo.IsFromProject) - ' ' Se modalità cloud, scrittura del file di punti - ' Dim bErrOnCloud As Boolean = False - - ' If bCloud Then - - ' If pattInfo.Cloud IsNot Nothing Then - - ' Using tw = New StreamWriter(Path.ChangeExtension(BtlPath, ".pnt"), False) - - ' For j As Integer = 0 To pattInfo.Cloud.Count() - 1 - ' Dim dPosX As Double = -pattInfo.Cloud(j).Y - ' Dim dPosY As Double = pattInfo.Cloud(j).X - ' Dim sPosX As String = dPosX.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture) - ' Dim sPosY As String = dPosY.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture) - ' tw.WriteLine(sPosX & " " & sPosY) - ' Next - ' End Using - ' Else - ' BtlOk = False - ' bErrOnCloud = True - ' End If - ' End If - ' ' Se scrittura Btl non riuscita - ' If Not BtlOk Then - ' ' scrivo direttamente il file di errore - ' Dim ErrCutId As Integer = (If(pattInfo.IsFromProject, pattInfo.ElementId, pattInfo.PatternId)) - - ' Using tw = New StreamWriter(Path.ChangeExtension(BtlPath, ".txt"), False) - ' tw.WriteLine("ERR=10") - ' tw.WriteLine(If(bErrOnCloud, "Cloud without points", "BTL without processes")) - ' tw.WriteLine("CUTID=" & ErrCutId.ToString()) - ' tw.WriteLine("TASKID=0") - ' End Using - ' ' elimino eventuale file Cn già presente - ' If parameters.UIMode = InOutParameters.UIModes.HIDDEN Then - ' Dim CncPath As String = Path.ChangeExtension(BtlPath, ".cnc") - ' If File.Exists(CncPath) Then File.Delete(CncPath) - ' End If - ' ' altrimenti - ' Else - ' ' cancello eventuale file di errore già presente - ' Dim TxtPath As String = Path.ChangeExtension(BtlPath, ".txt") - ' If File.Exists(TxtPath) Then File.Delete(TxtPath) - ' End If - ' ' Salvo dati - ' vBar(i).piInfo = pattInfo - ' vBar(i).nBarState = nBarState - ' vBar(i).sBtlPath = BtlPath - ' vBar(i).bBtlOk = BtlOk - 'Next - - ' Lancio in parallelo più processi (senza superare il numero di core logici presenti) - Dim vProc As MyProc() = New MyProc(nMaxThread - 1) {} - For j As Integer = 0 To nMaxThread - 1 - vProc(j).nBar = -1 - vProc(j).bEnable = True - Next - - ' Processo i Btl in parallelo - Dim nCurrBar As Integer = 0 - Dim nDoneBar As Integer = 0 - Dim nShiftBar As Integer = 0 - Dim nActProc As Integer = 0 - - While nCurrBar < numBars + nShiftBar OrElse nActProc > 0 - - For j As Integer = 0 To nMaxThread - 1 - If Not vProc(j).bEnable Then Continue For - Dim bDone As Boolean = False - - If vProc(j).nBar = -1 Then - - If nCurrBar < numBars + nShiftBar Then - - If vBar(nCurrBar).bBarOk Then - vProc(j).Proc = New Process() - vProc(j).Proc.StartInfo.FileName = ExePath - 'Dim nMode As Integer = CInt(parameters.UIMode) - 'If parameters.UIMode = InOutParameters.UIModes.HIDDEN AndAlso vBar(nCurrBar).nBarState <> 0 Then nMode = 4 - vProc(j).Proc.StartInfo.Arguments = """" & vBar(nCurrBar).sBarPath & """ " & """" & Map.refMachinePanelVM.SelectedMachine.nType & """ " & - """" & Map.refMachinePanelVM.SelectedMachine.Name & """ " & vBar(nCurrBar).nCmdType - vProc(j).Proc.StartInfo.UseShellExecute = False - - If vProc(j).Proc.Start() Then - vProc(j).nBar = nCurrBar - nCurrBar += 1 - nActProc += 1 - End If - Else - ProcessResults(vBar(nCurrBar)) ', vBar(nCurrBar).piInfo, parameters.UIMode) - bDone = True - nCurrBar += 1 - End If - End If - Else - - If vProc(j).Proc.HasExited Then - ' se terminato con successo - If vProc(j).Proc.ExitCode = 0 Then - ' salvo il risultato - ProcessResults(vBar(vProc(j).nBar)) ', vBar(vProc(j).nBar).piInfo, parameters.UIMode) - bDone = True - vProc(j).nBar = -1 - nActProc -= 1 - ' se superato il numero di processi eseguibili in parallelo - ElseIf vProc(j).Proc.ExitCode = 1 Then - ' aggiungo il pezzo in coda - If numBars + nShiftBar < numBars + nMaxThread Then - vBar(numBars + nShiftBar) = vBar(vProc(j).nBar) - nShiftBar += 1 - End If - ' disabilito il processo - vProc(j).bEnable = False - vProc(j).nBar = -1 - nActProc -= 1 - ' altrimenti (errore generico di esecuzione) - Else - ' salvo il risultato - ProcessResults(vBar(vProc(j).nBar)) ', parameters.UIMode) - bDone = True - vProc(j).nBar = -1 - nActProc -= 1 - End If - Else - vProc(j).Proc.Refresh() - End If - End If - - If bDone Then - ' Dialog con Progress Bar - dProgress += (0.9 / numBars) - nDoneBar += 1 - Dim sProg As String = (dProgress * 100).ToString("F1", CultureInfo.InvariantCulture) - callback(dProgress, " Progress: " & sProg & "% Count: " & nDoneBar & " / " & numBars, bCancel) - - If bCancel Then - ' fine - callback(1, "", bCancel) - Return - End If - End If - - Thread.Sleep(1) - Next - - ' Verifico che i processi non siano andati tutti in errore - Dim bAllKO As Boolean = True - - For j As Integer = 0 To nMaxThread - 1 - If vProc(j).bEnable Then bAllKO = False - Next - - If bAllKO Then - MessageBox.Show("Execution error (all processes are disabled)") - Exit While - End If - - Thread.Sleep(10) - End While - - 'callback.Progress(1, "End", bCancel) - Thread.Sleep(300) - ' fine - callback(1, "Done", bCancel) - End Sub - - 'Public Sub Abort() - 'End Sub - - Private Shared Sub ProcessResults(ByVal Bar As Bar) ' , ByVal pattInfo As PatternInfo, ByVal UIMode As InOutParameters.UIModes) - 'If UIMode = InOutParameters.UIModes.SHOWUI OrElse UIMode = InOutParameters.UIModes.SIMULAZIONE Then Return - Dim BtlPath As String = Bar.sBarPath - Dim bErrors As Boolean = False - Dim nLastErr As Integer = 0 - Dim sLastMsg As String = "" - Dim nCurrCutId As Integer = 0 - 'Dim dctErr As Dictionary(Of Integer, PatternInfo.Results) = New Dictionary(Of Integer, PatternInfo.Results)() - 'Dim dctRot As Dictionary(Of Integer, Double) = New Dictionary(Of Integer, Double)() - Dim nTotTime As Integer = 0 - 'Dim resCurrExe As PatternInfo.Results = Nothing, dCurrRot As Double = Nothing - - If File.Exists(Path.ChangeExtension(BtlPath, ".txt")) Then - Dim nErr As Integer = 0 - Dim sMsg As String = "" - Dim dRot As Double = 0 - Dim cutId As Integer = 0 - Dim prevCutId As Integer = GDB_ID.NULL - Dim currBTLPart As BTLPart - Dim taskId As Integer = 0 - Dim lines As String() = System.IO.File.ReadAllLines(Path.ChangeExtension(BtlPath, ".txt")) - - For Each line As String In lines - - If line.StartsWith("ERR=") Then - Dim nVal As Integer? = GetVal(line, "ERR") - nErr = (If(nVal IsNot Nothing, nVal.Value, 0)) - sMsg = "" - cutId = 0 - taskId = 0 - ElseIf line.StartsWith("ROT=") Then - Dim nVal As Integer? = GetVal(line, "ROT") - Dim nRot As Integer = (If(nVal IsNot Nothing, nVal.Value, 0)) - dRot = ((4 - nRot) Mod 4) * 90 - ElseIf line.StartsWith("CUTID=") Then - Dim nVal As Integer? = GetVal(line, "CUTID") - cutId = (If(nVal IsNot Nothing, nVal.Value, 0)) - If cutId <> prevCutId Then - ' aggiornamento globale pezzo precedente - If cutId <> GDB_ID.NULL AndAlso cutId <> 0 Then - 'currBTLPart.CalcGlobalUpdate() - End If - ' aggiornamento risultati in struttura BTL - If Bar.nBarType = ProjectType.PROJ Then - ' cerco pezzo in btl structure da id - For Each Part In Map.refProjectVM.BTLStructure.PartList - If Part.nPartId = cutId Then - currBTLPart = Part - End If - Next - End If - End If - prevCutId = cutId - - 'If cutId <> nCurrCutId Then - ' nCurrCutId = cutId - ' dctErr.Clear() - ' dctRot.Clear() - 'End If - ElseIf line.StartsWith("TASKID=") Then - Dim nVal As Integer? = GetVal(line, "TASKID") - taskId = (If(nVal IsNot Nothing, nVal.Value, 0)) - 'Dim resExe As PatternInfo.Results = PatternInfo.Results.OK - - 'If nErr = 22 Then - ' resExe = PatternInfo.Results.COLLISION - ' bErrors = True - - ' If cutId = 0 OrElse taskId = 0 Then - ' nLastErr = nErr - ' sLastMsg = sMsg - ' End If - 'ElseIf nErr > 0 Then - ' resExe = PatternInfo.Results.WARNING - ' bErrors = True - - ' If cutId = 0 OrElse taskId = 0 Then - ' nLastErr = nErr - ' sLastMsg = sMsg - ' End If - 'End If - - 'se taskid diverso da zero, errore feature - If taskId <> 0 Then - EgtSetInfo(taskId, ITG_ERR, nErr) - EgtSetInfo(taskId, ITG_MSG, sMsg) - EgtSetInfo(taskId, ITG_ROT, dRot) - ' aggiornamento risultati in struttura BTL - If Bar.nBarType = ProjectType.PROJ Then - ' cerco task in btl structure da id - If Not IsNothing(currBTLPart) Then - For Each Feature In currBTLPart.FeatureList - If Feature.nFeatureId = taskId Then - Feature.CalcFeatureUpdate(True, nErr, dRot, sMsg) - End If - Next - End If - End If - - 'se taskid uguale a zero, errore pezzo - Else - EgtSetInfo(cutId, ITG_ERR, nErr) - EgtSetInfo(cutId, ITG_MSG, sMsg) - EgtSetInfo(cutId, ITG_ROT, dRot) - ' aggiorno in struttura btl - If Not IsNothing(currBTLPart) Then currBTLPart.CalcPartUpdate(True, nErr, dRot, sMsg) - - End If - - - 'If taskId <> 0 Then - - ' If dctErr.TryGetValue(taskId, resCurrExe) Then - - ' If resExe > resCurrExe Then - ' dctErr(taskId) = resExe - ' pattInfo.SetTaskState(cutId, taskId, resExe, sMsg) - ' End If - ' Else - ' dctErr(taskId) = resExe - ' pattInfo.SetTaskState(cutId, taskId, resExe, sMsg) - ' End If - 'Else - ' pattInfo.SetTaskState(cutId, taskId, resExe, sMsg) - 'End If - - 'If taskId <> 0 Then - - ' If dctRot.TryGetValue(taskId, dCurrRot) Then - - ' If Math.Abs(dRot) > 1 Then - ' If Math.Abs(dCurrRot) < 1 Then dctRot(taskId) = dRot - ' Else - ' dRot = dCurrRot - ' End If - ' Else - ' dctRot.Add(taskId, dRot) - ' End If - 'End If - - 'If pattInfo.IsFromProject Then - ' pattInfo.SetProcessInfoChosen(cutId, taskId, dRot, 0, False) - 'Else - ' pattInfo.SetTaskInfoChosen(cutId, taskId, dRot, 0, False) - 'End If - ElseIf line.StartsWith("TIME=") Then - Dim nVal As Integer? = GetVal(line, "TIME") - nTotTime = (If(nVal IsNot Nothing, nVal.Value, 0)) - EgtSetInfo(cutId, ITG_TIME, nTotTime) - ElseIf Not String.IsNullOrWhiteSpace(line) AndAlso line <> "---" Then - sMsg = line - End If - Next - Else - bErrors = True - nLastErr = 25 - sLastMsg = "Execution Error" - End If - - ' aggiornamento risultati in struttura BTL - If Bar.nBarType = ProjectType.PROJ Then - ' cerco pezzo in btl structure da id - For Each Part In Map.refProjectVM.BTLStructure.PartList - If Part.nPartId = Bar.nBarId Then - ' leggo errori da geometria e li aggiorno in struttura btl - Part.CalcFeatureUpdate() - End If - Next - - End If - - 'pattInfo.IsDone = True - - 'If Not bErrors Then - ' pattInfo.Result = PatternInfo.Results.OK - ' pattInfo.DetailResult = PatternInfo.DetailResults.MEMORY - 'Else - - ' If nLastErr = 17 Then - ' pattInfo.Result = PatternInfo.Results.[ERROR] - ' pattInfo.DetailResult = PatternInfo.DetailResults.ALL_WARNING - ' pattInfo.Message = sLastMsg - ' ElseIf nLastErr = 19 Then - ' pattInfo.Result = PatternInfo.Results.[ERROR] - ' pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR - ' pattInfo.Message = sLastMsg - ' ElseIf nLastErr = 22 Then - ' pattInfo.Result = PatternInfo.Results.[ERROR] - ' pattInfo.DetailResult = PatternInfo.DetailResults.ALL_COLLISION - ' pattInfo.Message = sLastMsg - ' ElseIf nLastErr = 23 Then - ' pattInfo.Result = PatternInfo.Results.[ERROR] - ' pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR - ' pattInfo.Message = sLastMsg - ' ElseIf nLastErr = 24 Then - ' pattInfo.Result = PatternInfo.Results.[ERROR] - ' pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR - ' pattInfo.Message = sLastMsg - ' ElseIf nLastErr = 25 Then - ' pattInfo.Result = PatternInfo.Results.[ERROR] - ' pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR - ' pattInfo.Message = sLastMsg - ' Else - ' pattInfo.Result = PatternInfo.Results.[ERROR] - ' pattInfo.DetailResult = PatternInfo.DetailResults.MEMORY - ' End If - 'End If - - 'pattInfo.EstimatedTime = nTotTime - - 'If Not bErrors AndAlso (UIMode = InOutParameters.UIModes.HIDDEN OrElse UIMode = InOutParameters.UIModes.CLOUD) Then - ' Dim CncPath As String = Path.ChangeExtension(BtlPath, ".cnc") - - ' If File.Exists(CncPath) Then - ' Dim lines As String = System.IO.File.ReadAllText(CncPath) - ' pattInfo.Iso = lines - ' pattInfo.Result = PatternInfo.Results.OK - ' pattInfo.DetailResult = PatternInfo.DetailResults.ALL_OK - ' Else - ' pattInfo.Iso = "" - ' pattInfo.Result = PatternInfo.Results.[ERROR] - ' pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR - ' End If - 'End If - End Sub - - 'Public Shared Sub GetListaTasks(ByVal btlObject As BTL) - ' Dim dTab As DataTable = _ds.Tables(0) - ' Dim listaTasksCount As Int32 = dTab.Rows.Count - ' If listaTasksCount = 0 Then Return - ' Dim dRow0 As DataRow = dTab.Rows(0) - ' btlObject.projectNumber = dRow0("projectId").ToString() - ' btlObject.barLength = GetBarLengthP(CInt(dRow0("patternId")), CInt(dRow0("productionId"))).ToString("F3", CultureInfo.InvariantCulture) - ' btlObject.barLoad90 = GetBarLoad90P(CInt(dRow0("patternId")), CInt(dRow0("productionId"))).ToString(CultureInfo.InvariantCulture) - ' btlObject.panelLength = GetBarLengthP(CInt(dRow0("patternId")), CInt(dRow0("productionId"))).ToString("F3", CultureInfo.InvariantCulture) - ' btlObject.panelWidth = GetBarWidthP(CInt(dRow0("patternId")), CInt(dRow0("productionId"))).ToString("F3", CultureInfo.InvariantCulture) - ' btlObject.productionId = CInt(dRow0("productionId")) - ' btlObject.patternId = CInt(dRow0("patternId")) - ' btlObject.parts = New List(Of BTL.Part)() - ' Dim ListaCutParts As List(Of Integer) = GetListaCutIdP() - - ' For c As Integer = 0 To ListaCutParts.Count - 1 - ' Dim readPart As BTL.Part = New BTL.Part() - ' Dim bFirst As Boolean = True - - ' For f As Integer = 0 To listaTasksCount - 1 - ' Dim dRowF As DataRow = dTab.Rows(f) - ' If CInt(dRowF("cutId")) <> ListaCutParts(c) Then Continue For - - ' If bFirst Then - ' readPart.singleMemberNumber = GetElementSN(CInt(dRowF("elementId")), CInt(dRowF("projectId"))) - ' readPart.count = "1" - ' readPart.length = dRowF("length").ToString() - ' readPart.height = dRowF("height").ToString() - ' readPart.width = dRowF("width").ToString() - ' readPart.x = CDbl(dRowF("x")) - ' readPart.z = CDbl(dRowF("z")) - ' readPart.inverted = CDbl(dRowF("inverted")) - ' readPart.rotated = CDbl(dRowF("rotated")) - ' readPart.cutId = CInt(dRowF("cutId")) - ' bFirst = False - ' readPart.features = New List(Of BTL.Feature)() - ' End If - - ' If String.IsNullOrEmpty(dRowF("taskId").ToString()) Then Continue For - ' Dim readFeature As BTL.Feature = New BTL.Feature() With { - ' .taskId = dRowF("taskId").ToString(), - ' .processKey = dRowF("group").ToString() & "-" & dRowF("key").ToString().Substring(1, 3) & "-" & dRowF("face").ToString(), - ' .designation = dRowF("des").ToString(), - ' .processIdent = dRowF("processIdent").ToString(), - ' .sag1 = dRowF("sag1").ToString(), - ' .Text = dRowF("text").ToString(), - ' .Process = If((Convert.ToInt16(dRowF("enabled")) = 1), "YES", "NO"), - ' .processParameters = New List(Of String)(46) From { - ' dRowF("p01").ToString(), - ' dRowF("p02").ToString(), - ' dRowF("p03").ToString(), - ' dRowF("p04").ToString(), - ' dRowF("p05").ToString(), - ' dRowF("p06").ToString(), - ' dRowF("p07").ToString(), - ' dRowF("p08").ToString(), - ' dRowF("p09").ToString(), - ' dRowF("p10").ToString(), - ' dRowF("p11").ToString(), - ' dRowF("p12").ToString(), - ' dRowF("p13").ToString(), - ' dRowF("p14").ToString(), - ' dRowF("p15").ToString(), - ' dRowF("p16").ToString(), - ' dRowF("p17").ToString(), - ' dRowF("p18").ToString(), - ' dRowF("p19").ToString(), - ' dRowF("p20").ToString(), - ' dRowF("p21").ToString(), - ' dRowF("p22").ToString(), - ' dRowF("p23").ToString(), - ' dRowF("p24").ToString(), - ' dRowF("p25").ToString(), - ' dRowF("p26").ToString(), - ' dRowF("q01").ToString(), - ' dRowF("q02").ToString(), - ' dRowF("q03").ToString(), - ' dRowF("q04").ToString(), - ' dRowF("q05").ToString(), - ' dRowF("q06").ToString(), - ' dRowF("q07").ToString(), - ' dRowF("q08").ToString(), - ' dRowF("q09").ToString(), - ' dRowF("q10").ToString(), - ' dRowF("q11").ToString(), - ' dRowF("q12").ToString(), - ' dRowF("q13").ToString(), - ' dRowF("q14").ToString(), - ' dRowF("q15").ToString(), - ' dRowF("q16").ToString(), - ' dRowF("q17").ToString(), - ' dRowF("q18").ToString(), - ' dRowF("q19").ToString(), - ' dRowF("q20").ToString() - ' }, - ' .processReference = New List(Of String)(9) From { - ' dRowF("ox").ToString(), - ' dRowF("oy").ToString(), - ' dRowF("oz").ToString(), - ' dRowF("xx").ToString(), - ' dRowF("xy").ToString(), - ' dRowF("xz").ToString(), - ' dRowF("yx").ToString(), - ' dRowF("yy").ToString(), - ' dRowF("yz").ToString() - ' } - ' } - ' readPart.features.Add(readFeature) - ' Next - - ' btlObject.parts.Add(readPart) - ' Next - - ' btlObject.parts.Sort(Function(p, q) p.x.CompareTo(q.x)) - 'End Sub - - Private Shared Function GetVal(ByVal sText As String, ByVal sKey As String) As Integer? - Dim sParts As String() = sText.Split("="c) - If String.Compare(sParts(0), sKey) <> 0 Then Return Nothing - Dim nVal As Integer = Nothing - - If Not Integer.TryParse(sParts(1), nVal) Then - Return Nothing - Else - Return nVal - End If - End Function - - 'Public Shared Sub GetListaProcesses(ByVal btlObject As BTL) - ' Dim dTab As DataTable = _ds.Tables(0) - ' Dim listaProcessesCount As Integer = dTab.Rows.Count - - ' If listaProcessesCount = 0 Then - ' btlObject.parts = Nothing - ' Return - ' End If - - ' Dim dRow0 As DataRow = dTab.Rows(0) - ' btlObject.projectNumber = dRow0("projectId").ToString() - ' btlObject.barLength = GetBarLengthO(CInt(dRow0("elementId")), CInt(dRow0("projectId"))).ToString("F3", CultureInfo.InvariantCulture) - ' btlObject.barLoad90 = "0" - ' btlObject.panelLength = GetPanelLengthO(CInt(dRow0("elementId")), CInt(dRow0("projectId"))).ToString("F3", CultureInfo.InvariantCulture) - ' btlObject.panelWidth = GetPanelWidthO(CInt(dRow0("elementId")), CInt(dRow0("projectId"))).ToString("F3", CultureInfo.InvariantCulture) - ' btlObject.projectId = CInt(dRow0("projectId")) - ' btlObject.elementId = CInt(dRow0("elementId")) - ' btlObject.parts = New List(Of BTL.Part)() - ' Dim ListaCutParts As List(Of Integer) = New List(Of Integer)(1) - ' ListaCutParts.Add(CInt(dRow0("elementId"))) - - ' For c As Integer = 0 To ListaCutParts.Count - 1 - ' Dim readPart As BTL.Part = New BTL.Part() - ' Dim bFirst As Boolean = True - - ' For f As Integer = 0 To listaProcessesCount - 1 - ' Dim dRowF As DataRow = dTab.Rows(f) - ' If CInt(dRowF("elementId")) <> ListaCutParts(c) Then Continue For - - ' If bFirst Then - ' readPart.singleMemberNumber = GetElementSN(CInt(dRow0("elementId")), CInt(dRow0("projectId"))) - ' readPart.count = "1" - ' readPart.length = dRowF("length").ToString() - ' readPart.height = dRowF("height").ToString() - ' readPart.width = dRowF("width").ToString() - ' readPart.x = Constants.HeadOverMat - ' readPart.z = Constants.HeadOverMat - ' readPart.inverted = CDbl(dRowF("inverted")) - ' readPart.rotated = CDbl(dRowF("rotated")) - ' readPart.elementId = CInt(dRowF("elementId")) - ' bFirst = False - ' readPart.features = New List(Of BTL.Feature)() - ' End If - - ' If String.IsNullOrEmpty(dRowF("processId").ToString()) Then Continue For - ' Dim readFeature As BTL.Feature = New BTL.Feature() With { - ' .processId = dRowF("processId").ToString(), - ' .processKey = dRowF("group").ToString() & "-" & dRowF("key").ToString().Substring(1, 3) & "-" & dRowF("face").ToString(), - ' .designation = dRowF("des").ToString(), - ' .processIdent = dRowF("processIdent").ToString(), - ' .sag1 = dRowF("sag1").ToString(), - ' .Text = dRowF("text").ToString(), - ' .Process = If((Convert.ToInt16(dRowF("enabled")) = 1), "YES", "NO"), - ' .processParameters = New List(Of String)(46) From { - ' dRowF("p01").ToString(), - ' dRowF("p02").ToString(), - ' dRowF("p03").ToString(), - ' dRowF("p04").ToString(), - ' dRowF("p05").ToString(), - ' dRowF("p06").ToString(), - ' dRowF("p07").ToString(), - ' dRowF("p08").ToString(), - ' dRowF("p09").ToString(), - ' dRowF("p10").ToString(), - ' dRowF("p11").ToString(), - ' dRowF("p12").ToString(), - ' dRowF("p13").ToString(), - ' dRowF("p14").ToString(), - ' dRowF("p15").ToString(), - ' dRowF("p16").ToString(), - ' dRowF("p17").ToString(), - ' dRowF("p18").ToString(), - ' dRowF("p19").ToString(), - ' dRowF("p20").ToString(), - ' dRowF("p21").ToString(), - ' dRowF("p22").ToString(), - ' dRowF("p23").ToString(), - ' dRowF("p24").ToString(), - ' dRowF("p25").ToString(), - ' dRowF("p26").ToString(), - ' dRowF("q01").ToString(), - ' dRowF("q02").ToString(), - ' dRowF("q03").ToString(), - ' dRowF("q04").ToString(), - ' dRowF("q05").ToString(), - ' dRowF("q06").ToString(), - ' dRowF("q07").ToString(), - ' dRowF("q08").ToString(), - ' dRowF("q09").ToString(), - ' dRowF("q10").ToString(), - ' dRowF("q11").ToString(), - ' dRowF("q12").ToString(), - ' dRowF("q13").ToString(), - ' dRowF("q14").ToString(), - ' dRowF("q15").ToString(), - ' dRowF("q16").ToString(), - ' dRowF("q17").ToString(), - ' dRowF("q18").ToString(), - ' dRowF("q19").ToString(), - ' dRowF("q20").ToString() - ' }, - ' .processReference = New List(Of String)(9) From { - ' dRowF("ox").ToString(), - ' dRowF("oy").ToString(), - ' dRowF("oz").ToString(), - ' dRowF("xx").ToString(), - ' dRowF("xy").ToString(), - ' dRowF("xz").ToString(), - ' dRowF("yx").ToString(), - ' dRowF("yy").ToString(), - ' dRowF("yz").ToString() - ' } - ' } - ' readPart.features.Add(readFeature) - ' Next - - ' btlObject.parts.Add(readPart) - ' Next - - ' btlObject.parts.Sort(Function(p, q) p.x.CompareTo(q.x)) - 'End Sub - - 'Private Shared Function GetListaCutIdP() As List(Of Integer) - ' Dim ListaCutId As List(Of Integer) = New List(Of Integer)() - ' Dim dTab As DataTable = _ds.Tables(0) - ' Dim listaTasksCount As Integer = dTab.Rows.Count - - ' For f As Integer = 0 To listaTasksCount - 1 - ' Dim nCut As Integer = CInt(dTab.Rows(f)("cutId")) - ' If Not ListaCutId.Contains(nCut) Then ListaCutId.Add(nCut) - ' Next - - ' Return ListaCutId - 'End Function - - 'Private Shared Function GetElementSN(ByVal ElementId As Integer, ByVal ProjectId As Integer) As String - ' Dim SN As String = "000" - ' Dim sqlElementSN As String = "SELECT sn " & "FROM dbo.vw_Element " & "WHERE elementId = @firstId " & "AND projectId = @secondId" - - ' Using cn As SqlConnection = New SqlConnection(_SqlConnectionStr) - ' cn.Open() - - ' Using sqlCommand As SqlCommand = New SqlCommand(sqlElementSN, cn) - ' sqlCommand.Parameters.Add("@firstId", SqlDbType.Int) - ' sqlCommand.Parameters.Add("@secondId", SqlDbType.Int) - ' sqlCommand.Parameters("@firstId").Value = ElementId - ' sqlCommand.Parameters("@secondId").Value = ProjectId - ' Dim reader As SqlDataReader = sqlCommand.ExecuteReader() - - ' While reader.Read() - ' SN = Convert.ToString(reader("sn")) - ' End While - ' End Using - ' End Using - - ' Return SN - 'End Function - - 'Private Shared Function GetBarLengthP(ByVal patternId As Integer, ByVal productionId As Integer) As Double - ' Dim barLength As Double = 0 - ' Dim sqlBarLength As String = "SELECT l " & "FROM dbo.vw_Pattern " & "WHERE patternId = @firstId " & "AND productionId = @secondId" - - ' Using cn As SqlConnection = New SqlConnection(_SqlConnectionStr) - ' cn.Open() - - ' Using sqlCommand As SqlCommand = New SqlCommand(sqlBarLength, cn) - ' sqlCommand.Parameters.Add("@firstId", SqlDbType.Int) - ' sqlCommand.Parameters.Add("@secondId", SqlDbType.Int) - ' sqlCommand.Parameters("@firstId").Value = patternId - ' sqlCommand.Parameters("@secondId").Value = productionId - ' Dim reader As SqlDataReader = sqlCommand.ExecuteReader() - - ' While reader.Read() - ' barLength = Convert.ToDouble(reader("l")) - ' End While - ' End Using - ' End Using - - ' Return barLength - 'End Function - - 'Private Shared Function GetBarWidthP(ByVal patternId As Integer, ByVal productionId As Integer) As Double - ' Dim barWidth As Double = 0 - ' Dim sqlBarWidth As String = "SELECT w " & "FROM dbo.vw_Pattern " & "WHERE patternId = @firstId " & "AND productionId = @secondId" - - ' Using cn As SqlConnection = New SqlConnection(_SqlConnectionStr) - ' cn.Open() - - ' Using sqlCommand As SqlCommand = New SqlCommand(sqlBarWidth, cn) - ' sqlCommand.Parameters.Add("@firstId", SqlDbType.Int) - ' sqlCommand.Parameters.Add("@secondId", SqlDbType.Int) - ' sqlCommand.Parameters("@firstId").Value = patternId - ' sqlCommand.Parameters("@secondId").Value = productionId - ' Dim reader As SqlDataReader = sqlCommand.ExecuteReader() - - ' While reader.Read() - ' barWidth = Convert.ToDouble(reader("w")) - ' End While - ' End Using - ' End Using - - ' Return barWidth - 'End Function - - 'Private Shared Function GetBarLoad90P(ByVal patternId As Integer, ByVal productionId As Integer) As Integer - ' Dim nLoad90 As Integer = 0 - ' Dim sqlBarLength As String = "SELECT load90 " & "FROM dbo.vw_Pattern " & "WHERE patternId = @firstId " & "AND productionId = @secondId" - - ' Using cn As SqlConnection = New SqlConnection(_SqlConnectionStr) - ' cn.Open() - - ' Using sqlCommand As SqlCommand = New SqlCommand(sqlBarLength, cn) - ' sqlCommand.Parameters.Add("@firstId", SqlDbType.Int) - ' sqlCommand.Parameters.Add("@secondId", SqlDbType.Int) - ' sqlCommand.Parameters("@firstId").Value = patternId - ' sqlCommand.Parameters("@secondId").Value = productionId - ' Dim reader As SqlDataReader = sqlCommand.ExecuteReader() - - ' While reader.Read() - ' nLoad90 = Convert.ToInt32(reader("load90")) - ' End While - ' End Using - ' End Using - - ' Return nLoad90 - 'End Function - - 'Private Shared Function GetBarStateP(ByVal patternId As Integer, ByVal productionId As Integer) As Integer - ' Dim barState As Integer = 16 - ' Dim sqlBarLength As String = "SELECT state " & "FROM dbo.vw_Pattern " & "WHERE patternId = @firstId " & "AND productionId = @secondId" - - ' Using cn As SqlConnection = New SqlConnection(_SqlConnectionStr) - ' cn.Open() - - ' Using sqlCommand As SqlCommand = New SqlCommand(sqlBarLength, cn) - ' sqlCommand.Parameters.Add("@firstId", SqlDbType.Int) - ' sqlCommand.Parameters.Add("@secondId", SqlDbType.Int) - ' sqlCommand.Parameters("@firstId").Value = patternId - ' sqlCommand.Parameters("@secondId").Value = productionId - ' Dim reader As SqlDataReader = sqlCommand.ExecuteReader() - - ' While reader.Read() - ' barState = Convert.ToInt32(reader("state")) - ' End While - ' End Using - ' End Using - - ' Return barState - 'End Function - - 'Private Shared Function GetBarLengthO(ByVal elementId As Integer, ByVal projectId As Integer) As Double - ' Dim barLength As Double = 0 - ' Dim dTab As DataTable = _ds.Tables(0) - ' Dim listaProcessesCount As Integer = dTab.Rows.Count - - ' If listaProcessesCount > 0 Then - ' Dim beamLength As Double = Convert.ToDouble(dTab.Rows(0)("length")) - - ' If beamLength < Constants.BarMaxLenForAdd Then - ' barLength = beamLength + Constants.BarAddLen - ' Else - ' barLength = beamLength + 2 * Constants.HeadOverMat - ' End If - ' End If - - ' Return barLength - 'End Function - - 'Private Shared Function GetPanelLengthO(ByVal elementId As Integer, ByVal projectId As Integer) As Double - ' Dim panelLength As Double = 0 - ' Dim dTab As DataTable = _ds.Tables(0) - ' Dim listaProcessesCount As Integer = dTab.Rows.Count - - ' If listaProcessesCount > 0 Then - ' Dim wallLength As Double = Convert.ToDouble(dTab.Rows(0)("length")) - ' panelLength = wallLength + 2 * Constants.PanelOverMat - ' End If - - ' Return panelLength - 'End Function - - 'Private Shared Function GetPanelWidthO(ByVal elementId As Integer, ByVal projectId As Integer) As Double - ' Dim panelWidth As Double = 0 - ' Dim dTab As DataTable = _ds.Tables(0) - ' Dim listaProcessesCount As Integer = dTab.Rows.Count - - ' If listaProcessesCount > 0 Then - ' Dim wallWidth As Double = Convert.ToDouble(dTab.Rows(0)("width")) - ' panelWidth = wallWidth + 2 * Constants.PanelOverMat - ' End If - - ' Return panelWidth - 'End Function - - 'Private Shared Function GetExePath(ByVal parameters As InOutParameters) As String - ' Return parameters.Read("EGALTECH", "PATH_EXE", "") - 'End Function - - 'Private Shared Function GetDataDir(ByVal parameters As InOutParameters) As String - ' Dim DataDir As String = parameters.Read("EGALTECH", "DIR_DATA", "") - ' Dim di As DirectoryInfo = New DirectoryInfo(DataDir) - ' If Not di.Exists Then di.Create() - ' Return DataDir - 'End Function - - 'Private Shared Function GetBtlPath(ByVal DataDir As String, ByVal pattInfo As PatternInfo) As String - ' Dim BtlDir, BtlName As String - - ' If pattInfo.IsFromProject Then - ' BtlDir = Path.Combine(DataDir, "Projs", pattInfo.ProjectId.ToString("D4")) - ' BtlName = "Part_" & pattInfo.ProjectId.ToString() & "_" + pattInfo.ElementId.ToString() & ".btl" - ' Else - ' BtlDir = Path.Combine(DataDir, "Prods", pattInfo.ProductionId.ToString("D4")) - ' BtlName = "Bar_" & pattInfo.ProductionId.ToString() & "_" + pattInfo.PatternId.ToString() & ".btl" - ' End If - - ' Dim di As DirectoryInfo = New DirectoryInfo(BtlDir) - ' If Not di.Exists Then di.Create() - ' Return Path.Combine(BtlDir, BtlName) - 'End Function - - 'Private Shared Function GetMaxInstances(ByVal parameters As InOutParameters) As Integer - ' Dim sMaxInst As String = parameters.Read("EGALTECH", "MaxInstances", "1") - ' Dim nVal As Integer = Nothing - - ' If Not Integer.TryParse(sMaxInst, nVal) Then - ' Return 1 - ' Else - ' Return Math.Max(nVal, 1) - ' End If - 'End Function - - 'Public Function ShowTools(ByVal parameters As InOutParameters) As Boolean - ' Dim ExePath As String = GetExePath(parameters) - ' Dim DataDir As String = GetDataDir(parameters) - ' Dim BtlPath As String = Path.Combine(DataDir, "QQQ.btl") - ' Dim process As Process = New Process() - ' process.StartInfo.FileName = ExePath - ' process.StartInfo.Arguments = """" & BtlPath & """ " & parameters.MachineName & " 11" - ' process.StartInfo.UseShellExecute = False - ' process.Start() - - ' While Not process.HasExited - ' process.Refresh() - ' Thread.Sleep(50) - ' End While - - ' Return True - 'End Function - - 'Public Function ShowJobs(ByVal parameters As InOutParameters) As Boolean - ' Dim ExePath As String = GetExePath(parameters) - ' Dim DataDir As String = GetDataDir(parameters) - ' Dim BtlPath As String = Path.Combine(DataDir, "QQQ.btl") - ' Dim process As Process = New Process() - ' process.StartInfo.FileName = ExePath - ' process.StartInfo.Arguments = """" & BtlPath & """ " & parameters.MachineName & " 12" - ' process.StartInfo.UseShellExecute = False - ' process.Start() - - ' While Not process.HasExited - ' process.Refresh() - ' Thread.Sleep(50) - ' End While - - ' Return True - 'End Function - - 'Public Function UpdateMachine(ByVal parameters As InOutParameters) As Boolean - ' GetMachineParams(parameters) - ' Return True - 'End Function - - ' - 'Private Shared Function WritePrivateProfileString(ByVal Section As String, ByVal Key As String, ByVal Value As String, ByVal FilePath As String) As Long - - ' Private Shared Sub GetMachineParams(ByVal parameters As InOutParameters) - ' Dim DataDir As String = GetDataDir(parameters) - ' Dim DataName As String = "Essetre-" & parameters.MachineName & ".data" - ' Dim DataPath As String = Path.Combine(DataDir, DataName) - ' If File.Exists(DataPath) Then File.Delete(DataPath) - ' _SqlConnectionStr = parameters.ConnectionString - ' Dim dsOffsets As DataSet = New DataSet() - ' Dim sqlOffsets As String = "SELECT [group], [key], [value] " & "FROM [ESSETRE].[dbo].[vw_MachineParam] " & "WHERE [group] = 'OFFSETS' AND configurationId = @ConfigId" - - ' Using cn As SqlConnection = New SqlConnection(_SqlConnectionStr) - ' cn.Open() - - ' Using cmd As SqlCommand = New SqlCommand(sqlOffsets, cn) - ' cmd.Parameters.Add("@ConfigId", SqlDbType.Int) - ' cmd.Parameters("@ConfigId").Value = parameters.ConfigurationId - ' Dim dataAdapter = New SqlDataAdapter(cmd) - ' dsOffsets.Clear() - ' dataAdapter.Fill(dsOffsets) - ' End Using - ' End Using - - ' _SqlConnectionStr = parameters.ConnectionString - ' Dim dsTrave As DataSet = New DataSet() - ' Dim sqlTrave As String = "SELECT [group], [key], [value] " & "FROM [ESSETRE].[dbo].[vw_MachineParam] " & "WHERE [group] = 'TRAVE' AND configurationId = @ConfigId" - - ' Using cn As SqlConnection = New SqlConnection(_SqlConnectionStr) - ' cn.Open() - - ' Using cmd As SqlCommand = New SqlCommand(sqlTrave, cn) - ' cmd.Parameters.Add("@ConfigId", SqlDbType.Int) - ' cmd.Parameters("@ConfigId").Value = parameters.ConfigurationId - ' Dim dataAdapter = New SqlDataAdapter(cmd) - ' dsTrave.Clear() - ' dataAdapter.Fill(dsTrave) - ' End Using - ' End Using - - ' _SqlConnectionStr = parameters.ConnectionString - ' Dim dsUser As DataSet = New DataSet() - ' Dim sqlUser As String = "SELECT [group], [key], [value] " & "FROM [ESSETRE].[dbo].[vw_ConfigurationParam] " & "WHERE [group] <> 'TEXTS' AND [group] <> 'PARAMS' AND configurationId = @ConfigId" - - ' Using cn As SqlConnection = New SqlConnection(_SqlConnectionStr) - ' cn.Open() - - ' Using cmd As SqlCommand = New SqlCommand(sqlUser, cn) - ' cmd.Parameters.Add("@ConfigId", SqlDbType.Int) - ' cmd.Parameters("@ConfigId").Value = parameters.ConfigurationId - ' Dim dataAdapter = New SqlDataAdapter(cmd) - ' dsUser.Clear() - ' dataAdapter.Fill(dsUser) - ' End Using - ' End Using - - ' Using tw = New StreamWriter(DataPath, False) - ' tw.WriteLine("-- " & DataPath) - ' tw.WriteLine("") - ' tw.WriteLine("local Offsets = {") - - ' For Each table As DataTable In dsOffsets.Tables - - ' For Each row As DataRow In table.Rows - ' Dim Key As String = row("key").ToString() - ' Dim Value As String = row("value").ToString() - ' tw.WriteLine(" " & Key & "=" & Value & ",") - ' Next - ' Next - - ' tw.WriteLine(" Zzz=1") - ' tw.WriteLine("}") - ' tw.WriteLine("") - ' tw.WriteLine("local Trave = {") - - ' For Each table As DataTable In dsTrave.Tables - - ' For Each row As DataRow In table.Rows - ' Dim Key As String = row("key").ToString() - ' Dim Value As String = row("value").ToString() - ' tw.WriteLine(" " & Key & "=" & Value & ",") - ' Next - ' Next - - ' tw.WriteLine(" Zzz=1") - ' tw.WriteLine("}") - ' tw.WriteLine("") - ' tw.WriteLine("local User = {") - - ' For Each table As DataTable In dsUser.Tables - - ' For Each row As DataRow In table.Rows - ' Dim Group As String = row("group").ToString() - ' Dim Key As String = row("key").ToString() - ' Dim Value As String = row("value").ToString() - ' tw.WriteLine(" " & Group & "_" & Key & "=" & Value & ",") - ' Next - ' Next - - ' tw.WriteLine(" Zzz=1") - ' tw.WriteLine("}") - ' tw.WriteLine("") - ' tw.WriteLine("local Machine = { Offsets=Offsets, Trave=Trave, User=User}") - ' tw.WriteLine("return Machine") - ' End Using - 'End Sub - - 'Public Sub CollectFile(ByVal parameters As InOutParameters, ByVal collector As FileCollector) - ' Dim sRoot As String = parameters.Read("EGALTECH", "DIR_EGT", "C:\TechnoEssetre7\EgalTech") - ' Dim sBeamDir As String = "EgtCAM5\Beam" - ' Dim sMachDir As String = "EgtCAM5\Machines\Essetre-" & parameters.MachineName - ' collector.SetRoot(sRoot) - ' collector.AddDirectory(Path.Combine(sRoot, sBeamDir)) - ' collector.AddDirectory(Path.Combine(sRoot, sMachDir)) - 'End Sub - -End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/MainWindow/MainWindowM.vb b/EgtBEAMWALL.ViewerOptimizer/MainWindow/MainWindowM.vb index 5fe3bdef..1629d9df 100644 --- a/EgtBEAMWALL.ViewerOptimizer/MainWindow/MainWindowM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/MainWindow/MainWindowM.vb @@ -219,8 +219,8 @@ Public Class MainWindowM ' Verifico abilitazione nesting automatico m_bAutoNestOption = Not String.IsNullOrWhiteSpace(sNestKey) ' Recupero livello e opzioni della chiave - Dim bKey As Boolean = EgtGetKeyLevel(5327, 2307, 1, m_nKeyLevel) And - EgtGetKeyOptions(5327, 2307, 1, m_nKeyOptions) + Dim bKey As Boolean = EgtGetKeyLevel(5327, 2308, 1, m_nKeyLevel) And + EgtGetKeyOptions(5327, 2308, 1, m_nKeyOptions) ' Inizializzazione generale di EgtInterface m_nDebug = GetMainPrivateProfileInt(S_GENERAL, K_DEBUG, 0) m_sLogFile = m_sTempDir & "\" & GENLOG_FILE_NAME.Replace("#", m_nInstance.ToString()) diff --git a/EgtBEAMWALL.ViewerOptimizer/My Project/AssemblyInfo.vb b/EgtBEAMWALL.ViewerOptimizer/My Project/AssemblyInfo.vb index 1136fc6f..31164bb7 100644 --- a/EgtBEAMWALL.ViewerOptimizer/My Project/AssemblyInfo.vb +++ b/EgtBEAMWALL.ViewerOptimizer/My Project/AssemblyInfo.vb @@ -70,5 +70,5 @@ Imports System.Windows ' by using the '*' as shown below: ' - - + + diff --git a/EgtBEAMWALL.ViewerOptimizer/ProdManager/ProdManagerVM.vb b/EgtBEAMWALL.ViewerOptimizer/ProdManager/ProdManagerVM.vb index 8a8ec887..53587d70 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ProdManager/ProdManagerVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/ProdManager/ProdManagerVM.vb @@ -230,6 +230,7 @@ Public Class ProdManagerVM End If End If If Map.refSceneHostVM.MainController.OpenProject(sFilePath, False) Then + SectionXMaterial.SetType(Map.refProjectVM.BTLStructureVM.nPROJTYPE) ' aggiorno le colonne in base al tipo progetto Map.refRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.nPROJTYPE) Map.refPartInRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.nPROJTYPE) diff --git a/EgtBEAMWALL.ViewerOptimizer/ProjManager/ProjManagerVM.vb b/EgtBEAMWALL.ViewerOptimizer/ProjManager/ProjManagerVM.vb index d24bb9bc..99d074e0 100644 --- a/EgtBEAMWALL.ViewerOptimizer/ProjManager/ProjManagerVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/ProjManager/ProjManagerVM.vb @@ -314,7 +314,11 @@ Public Class ProjManagerVM ' scrivo info proj su layer BtlInfo EgtSetInfo(nBTLInfoLayer, BTL_PRT_PROJ, nProjId) ' salvo il progetto - EgtSaveFile(sProjFileName, NGE.CMPTEXT) + If EgtSaveFile(sProjFileName, NGE.CMPTEXT) Then + SectionXMaterial.SetType(m_nProjType) + DbControllers.m_ProjController.UpdateInfo(nProjId, "Hand made", "", Date.MinValue, m_nProjType) + SetCurrProj(nProjId) + End If Else MessageBox.Show(EgtMsg(61876)) End If @@ -417,6 +421,7 @@ Public Class ProjManagerVM End If End If If Map.refSceneHostVM.MainController.OpenProject(sFilePath, False) Then + SectionXMaterial.SetType(Map.refProjectVM.BTLStructureVM.nPROJTYPE) ' aggiorno le colonne in base al tipo progetto Map.refRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.nPROJTYPE) Map.refPartInRawPartListVM.UpdateColumns(Map.refProjectVM.BTLStructureVM.nPROJTYPE) @@ -582,6 +587,7 @@ Public Class ProjManagerVM EgtOutLog("Errore nell'importazione BTL") End If If bOk Then + SectionXMaterial.SetType(m_nProjType) ' aggiorno Db Dim sBTLFileName As String = Path.GetFileNameWithoutExtension(sFile) 'UpdateBTLFileName(nProjId, sBTLFileName)