diff --git a/EgtBEAMWALL.Core/Constants/ConstIni.vb b/EgtBEAMWALL.Core/Constants/ConstIni.vb new file mode 100644 index 00000000..f62aeddd --- /dev/null +++ b/EgtBEAMWALL.Core/Constants/ConstIni.vb @@ -0,0 +1,119 @@ +'---------------------------------------------------------------------------- +' EgalTech 2015-2015 +'---------------------------------------------------------------------------- +' File : ConstIni.vb Data : 12.02.15 Versione : 1.6b3 +' Contenuto : Modulo costanti sezione e chiavi per file Ini. +' +' +' +' Modifiche : 12.02.15 DS Creazione modulo. +' +' +'---------------------------------------------------------------------------- + +Module ConstIni + + Public Const INI_FILE_NAME As String = "EgtBEAMWALL.ini" + + Public Const S_GENERAL As String = "General" + Public Const K_DEBUG As String = "Debug" + Public Const K_LICENCE As String = "Licence" + Public Const K_USERLEVEL As String = "UserLevel" + Public Const K_MAXINST As String = "MaxInstances" + Public Const K_MAXCAMINST As String = "MaxCamInstances" + Public Const K_INSTANCES As String = "Instances" + Public Const K_COMMANDLOG As String = "CommandLog" + Public Const K_MESSAGESDIR As String = "MessagesDir" + Public Const K_MESSAGES As String = "Messages" + Public Const K_WINPLACE As String = "WinPlace" + Public Const K_LASTPROJ As String = "LastProj" + Public Const K_AUTOLOADLASTPROJ As String = "AutoLoadLastProj" + Public Const K_LASTIMPDIR As String = "LastImpDir" + Public Const K_PROJSINDEX As String = "ProjsIndex" + Public Const K_PRODSINDEX As String = "ProdsIndex" + Public Const K_SUPPORT As String = "Support" + Public Const K_WAREHOUSE As String = "Warehouse" + + Public Const S_LANGUAGES As String = "Languages" + Public Const K_LANGUAGE As String = "Language" + + Public Const S_LUA As String = "Lua" + Public Const K_LIBSDIR As String = "LibsDir" + Public Const K_BASELIB As String = "BaseLib" + + Public Const S_GEOMDB As String = "GeomDB" + Public Const K_DEFAULTFONT As String = "DefaultFont" + Public Const K_NFEFONTDIR As String = "NfeFontDir" + Public Const K_DEFAULTCOLOR As String = "DefaultColor" + Public Const K_SAVETYPE As String = "SaveType" + + Public Const S_OPENGL As String = "OpenGL" + Public Const K_DOUBLEBUFFER As String = "DoubleBuffer" + Public Const K_COLORBITS As String = "ColorBits" + Public Const K_DEPTHBITS As String = "DepthBits" + Public Const K_DRIVER As String = "Driver" + + Public Const S_SCENE As String = "Scene" + Public Const K_BACKTOP As String = "BackTop" + Public Const K_BACKBOTTOM As String = "BackBottom" + Public Const K_SHOWGFRAME As String = "ShowGFrame" + Public Const K_MARK As String = "Mark" + Public Const K_SELSURF As String = "SelSurf" + Public Const K_SHOWMODE As String = "ShowMode" + Public Const K_SHOWBUILDING As String = "ShowBuilding" + Public Const K_CURVEDIR As String = "CurveDir" + Public Const K_SHOWTRIAADV As String = "ShowTriaAdv" + Public Const K_SHOWZMAP As String = "ShowZmap" + Public Const K_TEXMAXLINPIX As String = "TextureMaxLinPixels" + Public Const K_ZOOMWIN As String = "ZoomWin" + Public Const K_DISTLINE As String = "DistLine" + Public Const K_MMUNITS As String = "MmUnits" + + Public Const S_GRID As String = "Grid" + Public Const K_SHOWGRID As String = "ShowGrid" + Public Const K_SHOWFRAME As String = "ShowFrame" + Public Const K_SNAPSTEP As String = "SnapStep" + Public Const K_SNAPSTEPINCH As String = "SnapStepInch" + Public Const K_MINLINESSTEP As String = "MinLineSStep" + Public Const K_MAJLINESSTEP As String = "MajLineSStep" + Public Const K_EXTSSTEP As String = "ExtSStep" + Public Const K_MINLNCOLOR As String = "MinLnColor" + Public Const K_MAJLNCOLOR As String = "MajLnColor" + + Public Const S_IMPORT As String = "Import" + Public Const K_BTLFLAG As String = "BtlFlag" + Public Const K_WALLBTLFLAG As String = "WallBtlFlag" + + Public Const S_MACH As String = "Mach" + Public Const K_MACHINESDIR As String = "MachinesDir" + Public Const K_TOOLMAKERSDIR As String = "ToolMakersDir" + Public Const K_CURRMACH As String = "CurrMach" + Public Const K_PASSWORD As String = "Password" + + Public Const S_SIMUL As String = "Simul" + Public Const K_SLIDERX As String = "SliderX" + Public Const K_SLIDERVAL As String = "SliderVal" + + Public Const S_BEAM As String = "Beam" + Public Const K_CALCPATH As String = "CalcPath" + Public Const K_BEAMBASEDIR As String = "BaseDir" + Public Const K_BEAMBWEEXEC As String = "BweExec" + + Public Const S_WALL As String = "Wall" + Public Const K_WALLBASEDIR As String = "BaseDir" + Public Const K_WALLBWEEXEC As String = "BweExec" + + Public Const S_NEST As String = "Nest" + Public Const K_NESTEXEC As String = "NestExec" + Public Const K_SECTIONTIME As String = "SectionTime" + Public Const K_PARTTIME As String = "PartTime" + + Public Const S_BEAMWALL As String = "BeamWall" + Public Const K_BEAMWALLENABLE As String = "BtlEnable" + Public Const K_BEAMWALLBASEDIR As String = "BaseDir" + Public Const K_BEAMWALLBUTTON As String = "Button" + + Public Const S_MRUPROJFILES As String = "MruProjFiles" + Public Const S_MRUPRODFILES As String = "MruProdFiles" + +End Module diff --git a/EgtBEAMWALL.Core/EgtBEAMWALL.Core.vbproj b/EgtBEAMWALL.Core/EgtBEAMWALL.Core.vbproj index 90b0b86c..f6efb96c 100644 --- a/EgtBEAMWALL.Core/EgtBEAMWALL.Core.vbproj +++ b/EgtBEAMWALL.Core/EgtBEAMWALL.Core.vbproj @@ -82,11 +82,16 @@ + EgtDataGrid.xaml + + + + @@ -145,6 +150,7 @@ + diff --git a/EgtBEAMWALL.Core/Integration/CalcEndEventArgs.vb b/EgtBEAMWALL.Core/Integration/CalcEndEventArgs.vb new file mode 100644 index 00000000..2f66a63e --- /dev/null +++ b/EgtBEAMWALL.Core/Integration/CalcEndEventArgs.vb @@ -0,0 +1,24 @@ +Public Class CalcEndEventArgs + Inherits EventArgs + + Public Enum Results As Integer + NULL = 0 + OK = 1 + ERROR_ = 2 + End Enum + + Public m_End As Results + Public Property End_ As Results + Get + Return m_End + End Get + Private Set(value As Results) + m_End = value + End Set + End Property + + Sub New(Result As Results) + m_End = Result + End Sub + +End Class diff --git a/EgtBEAMWALL.Core/Integration/CalcIntegration.vb b/EgtBEAMWALL.Core/Integration/CalcIntegration.vb new file mode 100644 index 00000000..d52c9b75 --- /dev/null +++ b/EgtBEAMWALL.Core/Integration/CalcIntegration.vb @@ -0,0 +1,458 @@ +Imports System.IO +Imports System.Threading +Imports System.Globalization +Imports EgtUILib +Imports EgtWPFLib5 +Imports EgtBEAMWALL.Core.ConstBeam +Imports EgtBEAMWALL.Core + +Public Module CalcIntegration + + Private _thread As System.Threading.Thread + + Public Event Calc_Ended As EventHandler(Of CalcEndEventArgs) + Public Event Calc_ProcessResult As EventHandler(Of CalcResultEventArgs) + Public Event Calc_ProcessEnd As EventHandler(Of CalcProcessEndEventArgs) + + Public Enum CmdType As Integer + GENERATE = 0 + MODIFY = 1 + SIMULATE = 2 + CHECK = 3 + CHECKGEN = 4 + POINT_CLOUD = 5 + RAWPART = 6 + End Enum + + Private Structure MyProc + Public bEnable As Boolean + Public Proc As Process + Public nBar As Integer + End Structure + + Private m_MaxCamInstances As Integer = 1 + Public Sub SetMaxCamInstances(value As Integer) + m_MaxCamInstances = value + 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 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.nProgramPage = ProjectType.PROJ Then + Bar.sBarPath = CreateNewProjectFromPart(Bar.nBarId, sProjDirPath) + ElseIf Bar.nProgramPage = 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, m_MaxCamInstances) + + ' 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 + + Dim bAllKO As Boolean + + 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 & """ " & + """" & vBar(nCurrBar).nProjType & """ " & + """" & vBar(nCurrBar).nMachineName & """ " & 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 + RaiseEvent Calc_ProcessResult(Nothing, New CalcResultEventArgs(vBar(nCurrBar))) 'ProcessResults(vBar(nCurrBar)) + ElseIf vBar(nCurrBar).nCmdType = CmdType.GENERATE Then + RaiseEvent Calc_ProcessEnd(Nothing, New CalcProcessEndEventArgs(vBar(nCurrBar))) 'ProcessResults(vBar(nCurrBar)) + End If + 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 + RaiseEvent Calc_ProcessResult(Nothing, New CalcResultEventArgs(vBar(vProc(j).nBar))) ' ProcessResults(vBar(vProc(j).nBar)) + ElseIf vBar(vProc(j).nBar).nCmdType = CmdType.GENERATE Then + RaiseEvent Calc_ProcessEnd(Nothing, New CalcProcessEndEventArgs(vBar(vProc(j).nBar))) 'ProcessResults(vBar(nCurrBar)) + End If + 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 + RaiseEvent Calc_ProcessResult(Nothing, New CalcResultEventArgs(vBar(vProc(j).nBar))) ' ProcessResults(vBar(vProc(j).nBar)) + ElseIf vBar(vProc(j).nBar).nCmdType = CmdType.GENERATE Then + RaiseEvent Calc_ProcessEnd(Nothing, New CalcProcessEndEventArgs(vBar(vProc(j).nBar))) 'ProcessResults(vBar(nCurrBar)) + End If + 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 + RaiseEvent Calc_Ended(Nothing, New CalcEndEventArgs(CalcEndEventArgs.Results.OK)) + + 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 + bAllKO = True + + For j As Integer = 0 To nMaxThread - 1 + If vProc(j).bEnable Then bAllKO = False + Next + + If bAllKO Then + 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 + RaiseEvent Calc_Ended(Nothing, New CalcEndEventArgs(If(bAllKO, CalcEndEventArgs.Results.ERROR_, CalcEndEventArgs.Results.OK))) + End Sub + + Private 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 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 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 + +End Module + +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 nProgramPage As ProjectType + Public nProjType As BWType + Public nMachineName As String +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 + Public 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.Core/Integration/CalcProcessEndEventArgs.vb b/EgtBEAMWALL.Core/Integration/CalcProcessEndEventArgs.vb new file mode 100644 index 00000000..75f8dc89 --- /dev/null +++ b/EgtBEAMWALL.Core/Integration/CalcProcessEndEventArgs.vb @@ -0,0 +1,18 @@ +Public Class CalcProcessEndEventArgs + Inherits EventArgs + + Public m_Result As Bar + Public Property Result As Bar + Get + Return m_Result + End Get + Private Set(value As Bar) + m_Result = value + End Set + End Property + + Sub New(Result As Bar) + m_Result = Result + End Sub + +End Class diff --git a/EgtBEAMWALL.Core/Integration/CalcResultEventArgs.vb b/EgtBEAMWALL.Core/Integration/CalcResultEventArgs.vb new file mode 100644 index 00000000..7549062b --- /dev/null +++ b/EgtBEAMWALL.Core/Integration/CalcResultEventArgs.vb @@ -0,0 +1,24 @@ +Public Class CalcResultEventArgs + Inherits EventArgs + + Public Enum Results As Integer + NULL = 0 + OK = 1 + ERROR_ = 2 + End Enum + + Public m_Result As Bar + Public Property Result As Bar + Get + Return m_Result + End Get + Private Set(value As Bar) + m_Result = value + End Set + End Property + + Sub New(Result As Bar) + m_Result = Result + End Sub + +End Class diff --git a/EgtBEAMWALL.Core/MachGroupPanel/MyMachGroupVM.vb b/EgtBEAMWALL.Core/MachGroupPanel/MyMachGroupVM.vb index e346d4ee..466b75a9 100644 --- a/EgtBEAMWALL.Core/MachGroupPanel/MyMachGroupVM.vb +++ b/EgtBEAMWALL.Core/MachGroupPanel/MyMachGroupVM.vb @@ -306,7 +306,11 @@ Public MustInherit Class MyMachGroupVM ElseIf dtStartTime <> DateTime.MinValue Then ' barra iniziata Return Brushes.Green ElseIf m_bToBeProduced Then ' barra in attesa - Return Brushes.Yellow + If m_bCNReCalculated Then + Return Brushes.Yellow + Else + Return Brushes.Purple + End If Else ' barra in coda Return Brushes.White End If @@ -369,7 +373,19 @@ Public MustInherit Class MyMachGroupVM End Select End Get End Property -#End Region + + Public ReadOnly Property Produce_IsEnabled As Boolean + Get + Select Case nProduction_State + Case ItemState.Assigned, ItemState.Confirmed + Return True + Case Else + Return False + End Select + End Get + End Property + +#End Region ' Supervisor ' definizione comandi Private m_cmdDeleteMachGroup As ICommand @@ -398,6 +414,9 @@ Public MustInherit Class MyMachGroupVM NotifyPropertyChanged(NameOf(Calc_Background)) End Sub + Public Overridable Sub CALCEnd() + End Sub + #End Region ' METHODS Public MustOverride Sub RefreshPartList() @@ -443,7 +462,7 @@ Public MustInherit Class MyMachGroupVM End Sub ' funzione che aggiorna lo stato e gli errori dopo calcolo - Public Sub CalcGlobalUpdate() + Public Overridable Sub CalcGlobalUpdate() MyMachGroupM.nCALC_GlobalERR = nCALC_ERR MyMachGroupM.nCALC_GlobalState = nCALC_State For Each Part In MyMachGroupM.PartMList diff --git a/EgtBEAMWALL.Core/Utility/DisableModifiedMgr.vb b/EgtBEAMWALL.Core/Utility/DisableModifiedMgr.vb new file mode 100644 index 00000000..e4d6a67b --- /dev/null +++ b/EgtBEAMWALL.Core/Utility/DisableModifiedMgr.vb @@ -0,0 +1,16 @@ +Imports EgtUILib + +Public Class DisableModifiedMgr + + Private m_bOldEnMod As Boolean + + Sub New() + m_bOldEnMod = EgtGetEnableModified() + If m_bOldEnMod Then EgtDisableModified() + End Sub + + Public Sub ReEnable() + If m_bOldEnMod Then EgtEnableModified() + End Sub + +End Class diff --git a/EgtBEAMWALL.Supervisor/BTLParam/BTLFeatureVM.vb b/EgtBEAMWALL.Supervisor/BTLParam/BTLFeatureVM.vb index 48b1bad9..cd926c5d 100644 --- a/EgtBEAMWALL.Supervisor/BTLParam/BTLFeatureVM.vb +++ b/EgtBEAMWALL.Supervisor/BTLParam/BTLFeatureVM.vb @@ -48,6 +48,29 @@ Public Class BTLFeatureVM #Region "METHODS" + ' funzione che aggiorna lo stato e gli errori dopo calcolo + Friend Sub CalcFeatureUpdate(ERR As Integer, ROT As Integer, MSG As String) + EgtSetInfo(nFeatureId, If(Map.refMainMenuVM.SelPage = Pages.VIEW, ITG_PROJ_ERR, ITG_PROD_ERR), ERR, True) + EgtSetInfo(nFeatureId, If(Map.refMainMenuVM.SelPage = Pages.VIEW, ITG_PROJ_MSG, ITG_PROD_MSG), MSG, True) + EgtSetInfo(nFeatureId, If(Map.refMainMenuVM.SelPage = Pages.VIEW, ITG_PROJ_ROT, ITG_PROD_ROT), ROT, True) + m_BTLFeatureM.nCALC_ERR = ERR + m_BTLFeatureM.nCALC_ROT = ROT + m_BTLFeatureM.sCALC_MSG = MSG + If ERR = 0 Then + m_BTLFeatureM.nState = CalcStates.OK + ElseIf ERR = 17 Then + m_BTLFeatureM.nState = CalcStates.WARNING + ElseIf ERR > 0 Then + m_BTLFeatureM.nState = CalcStates.ERROR_ + ElseIf ERR < 0 Then + m_BTLFeatureM.nState = Core.CalcStates.INFO + End If + NotifyPropertyChanged(NameOf(Calc_Background)) + NotifyPropertyChanged(NameOf(CALC_ROT_Visibility)) + NotifyPropertyChanged(NameOf(CALC_ERR_Letter)) + NotifyPropertyChanged(NameOf(CALC_ERR_Foreground)) + End Sub + #End Region ' METHODS #Region "COMMANDS" diff --git a/EgtBEAMWALL.Supervisor/CALCPanel/CALCPanelVM.vb b/EgtBEAMWALL.Supervisor/CALCPanel/CALCPanelVM.vb new file mode 100644 index 00000000..073ac250 --- /dev/null +++ b/EgtBEAMWALL.Supervisor/CALCPanel/CALCPanelVM.vb @@ -0,0 +1,468 @@ +Imports System.IO +Imports EgtUILib +Imports EgtWPFLib5 +Imports EgtBEAMWALL.Core + +Public Class CALCPanelVM + Inherits VMBase + + Private m_CALCPanel_IsEnabled As Boolean = True + Public Property CALCPanel_IsEnabled As Boolean + Get + Return m_CALCPanel_IsEnabled + End Get + Set(value As Boolean) + m_CALCPanel_IsEnabled = value + End Set + End Property + + ' Definizione comandi + Private m_cmdVerify As ICommand + Private m_cmdVerifyAll As ICommand + Private m_cmdSimulate As ICommand + +#Region "Messages" + + Public ReadOnly Property Verify_ToolTip As String + Get + Return EgtMsg(61901) + End Get + End Property + + Public ReadOnly Property Simulate_ToolTip As String + Get + Return EgtMsg(61902) + End Get + End Property + +#End Region ' Messages + +#Region "CONSTRUCTORS" + + Sub New() + ' imposto riferimento in Map + Map.SetRefCALCPanelVM(Me) + Core.CalcIntegration.SetMaxCamInstances(1) + AddHandler Core.CalcIntegration.Calc_ProcessResult, AddressOf Calc_ProcessResult + AddHandler Core.CalcIntegration.Calc_Ended, AddressOf Calc_Ended + AddHandler Core.CalcIntegration.Calc_ProcessEnd, AddressOf Calc_ProcessEnded + End Sub + +#End Region ' CONSTRUCTORS + +#Region "METHODS" + + Friend Sub SetCalcPanelIsEnabled(bIsEnabled As Boolean) + m_CALCPanel_IsEnabled = bIsEnabled + NotifyPropertyChanged(NameOf(CALCPanel_IsEnabled)) + End Sub + + Private Sub Calc_ProcessResult(sender As Object, e As CalcResultEventArgs) + ProcessResults(e.m_Result) + End Sub + + Private Sub Calc_Ended(sender As Object, e As CalcEndEventArgs) + If e.End_ <> CalcEndEventArgs.Results.OK Then + MessageBox.Show("Execution error (all processes are disabled)") + End If + Map.refProjectVM.ManageIsEnabled(True) + Map.refMyStatusBarVM.ResetStopProgress() + End Sub + + Private Sub Calc_ProcessEnded(sender As Object, e As CalcProcessEndEventArgs) + Dim nRawid As Integer = e.m_Result.nBarId + If nRawid <= 0 Then Return + Dim Machgroup As MyMachGroupVM = GetMachgroupVMFromMachgroupId(nRawid) + Machgroup.CALCEnd() + End Sub + + 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 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 + ' 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, "") + ' Ciclo ... + Dim nCUTID As Integer = -1 + 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 + ' aggiorno nuovo pezzo + CurrPartVM = GetPartVMFromPartId(Line.nCUTID) + End If + Else + ' se CutId = 0 + ' riporto errore barra + CurrMachgroupVM = GetMachgroupVMFromMachgroupId(Bar.nBarId) + End If + ' se necessario recupero feature + If Line.nTASKID <> 0 Then + CurrBTLFeatureVM = GetFeatureVMFromPartId(CurrPartVM, Line.nTASKID) + Else + CurrBTLFeatureVM = Nothing + End If + Select Case Line.Type + Case ProcessResult.ProcessResultTypes.BAR + CurrMachgroupVM.CalcMachGroupUpdate(Line.nERR, Line.dROT, Line.sMSG) + Case ProcessResult.ProcessResultTypes.PART + CurrPartVM.CalcPartUpdate(Line.nERR, Line.dROT, Line.sMSG) + Case ProcessResult.ProcessResultTypes.TASKID + CurrBTLFeatureVM.CalcFeatureUpdate(Line.nERR, Line.dROT, Line.sMSG) + Case ProcessResult.ProcessResultTypes.FALL + CurrPartVM.CalcFallUpdate(Line.nFALL) + Case ProcessResult.ProcessResultTypes.TIME + If IsNothing(CurrMachgroupVM) Then CurrMachgroupVM = GetMachgroupVMFromMachgroupId(Bar.nBarId) + CurrMachgroupVM.CalcTimeUpdate(Line.nTIME) + End Select + Next + Machgroup = GetMachgroupVMFromMachgroupId(Bar.nBarId) + For Each Part In Machgroup.PartVMList + Part.CalcGlobalUpdate() + Next + Machgroup.CalcGlobalUpdate() + + 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.nProgramPage = 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 GetPartVMFromPartId(nPartId As Integer) As PartVM + For Each MachGroupVM As MyMachGroupVM In Map.refProjectVM.SupervisorMachGroupPanelVM.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.SupervisorMachGroupPanelVM.MachGroupVMList.FirstOrDefault(Function(x) x.Id = nMachGroupId) + 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 Region ' METHODS + +#Region "COMMANDS" + +#Region "Verify" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property Verify_Command As ICommand + Get + If m_cmdVerify Is Nothing Then + m_cmdVerify = New Command(AddressOf Verify) + End If + Return m_cmdVerify + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Friend Sub Verify() + If IsNothing(Map.refSupervisorManagerVM.CurrProd) Then Return + Dim ProjType As BWType = Map.refSupervisorManagerVM.CurrProd.nType + Dim BarList() As EgtBEAMWALL.Core.Bar + If Not IsNothing(Map.refSupervisorMachGroupPanelVM.SelectedMachGroup) Then + Dim TempBarList(0) As EgtBEAMWALL.Core.Bar + Dim MachineName As String = "" + EgtGetMachGroupMachineName(Map.refSupervisorMachGroupPanelVM.SelectedMachGroup.Id, MachineName) + Dim Bar As New EgtBEAMWALL.Core.Bar With {.nBarId = Map.refSupervisorMachGroupPanelVM.SelectedMachGroup.Id, + .nProgramPage = ProjectType.PROD, + .nProjType = ProjType, + .bBarOk = True, + .nMachineName = MachineName} + Dim SelMachGroup As MyMachGroupVM = Map.refSupervisorMachGroupPanelVM.SelectedMachGroup + Select Case SelMachGroup.nGlobalState + Case Core.CalcStates.OK, Core.CalcStates.INFO + Bar.nCmdType = CalcIntegration.CmdType.GENERATE + Case Else + Dim sMachGroupFilePath As String = Map.refSupervisorManagerVM.CurrProd.sProdDirPath & "\" & SelMachGroup.Name.ToString() & ".ori.bwe" + If File.Exists(sMachGroupFilePath) Then File.Delete(sMachGroupFilePath) + Bar.nCmdType = CalcIntegration.CmdType.CHECKGEN + End Select + TempBarList(0) = Bar + BarList = TempBarList + Else + Return + End If + ' disabilito interfaccia + Map.refProjectVM.ManageIsEnabled(False) + ' lancio calcolo + EgtBEAMWALL.Core.CalcIntegration.Run(BarList, Map.refSupervisorManagerVM.CurrProd.sProdDirPath, AddressOf ManageCalc) + End Sub + + Friend Sub VerifyMachGroup(MachGroup As MyMachGroupVM) + If IsNothing(Map.refSupervisorManagerVM.CurrProd) Then Return + Dim ProjType As BWType = Map.refSupervisorManagerVM.CurrProd.nType + Dim BarList() As EgtBEAMWALL.Core.Bar + If Not IsNothing(MachGroup) Then + Dim TempBarList(0) As EgtBEAMWALL.Core.Bar + Dim MachineName As String = "" + EgtGetMachGroupMachineName(MachGroup.Id, MachineName) + Dim Bar As New EgtBEAMWALL.Core.Bar With {.nBarId = MachGroup.Id, + .nProgramPage = ProjectType.PROD, + .nProjType = ProjType, + .bBarOk = True, + .nMachineName = MachineName} + Select Case MachGroup.nGlobalState + Case Core.CalcStates.OK, Core.CalcStates.INFO + Bar.nCmdType = CalcIntegration.CmdType.GENERATE + Case Else + Dim sMachGroupFilePath As String = Map.refSupervisorManagerVM.CurrProd.sProdDirPath & "\" & MachGroup.Name.ToString() & ".ori.bwe" + If File.Exists(sMachGroupFilePath) Then File.Delete(sMachGroupFilePath) + Bar.nCmdType = CalcIntegration.CmdType.CHECKGEN + End Select + TempBarList(0) = Bar + BarList = TempBarList + Else + Return + End If + ' disabilito interfaccia + Map.refProjectVM.ManageIsEnabled(False) + ' lancio calcolo + EgtBEAMWALL.Core.CalcIntegration.Run(BarList, Map.refSupervisorManagerVM.CurrProd.sProdDirPath, AddressOf ManageCalc) + End Sub + + ' funzione che gestisce risposta da thread di verifica, aggiorna progress e segnala comando di interruzione + Private Sub ManageCalc(dProgress As Double, sProgress As String, ByRef bCancel As Boolean) + If dProgress = 0 Then + Map.refMyStatusBarVM.SetLoadingProgress_Visibility(True) + Map.refMyStatusBarVM.SetStopProgress_IsActive(True) + Map.refMyStatusBarVM.SetStopProgress_IsEnabled(True) + Map.refMyStatusBarVM.SetOutputMessage(sProgress) + Map.refMyStatusBarVM.SetStopProgress_IsActive(True) + Map.refMyStatusBarVM.SetStopProgress_IsEnabled(True) + ElseIf dProgress = 1 Then + Map.refMyStatusBarVM.SetLoadingProgress_Visibility(False) + Map.refMyStatusBarVM.SetStopProgress_IsActive(False) + Map.refMyStatusBarVM.SetStopProgress_IsEnabled(False) + Map.refMyStatusBarVM.SetOutputMessage(sProgress, 3) + End If + bCancel = Map.refMyStatusBarVM.bStopProgress + Map.refMyStatusBarVM.SetLoadingProgress(dProgress * 100) + Map.refMyStatusBarVM.SetOutputMessage(sProgress) + End Sub + +#End Region ' Verify + +#Region "VerifyAll" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property VerifyAll_Command As ICommand + Get + If m_cmdVerifyAll Is Nothing Then + m_cmdVerifyAll = New Command(AddressOf VerifyAll) + End If + Return m_cmdVerifyAll + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Friend Sub VerifyAll() + If IsNothing(Map.refSupervisorManagerVM.CurrProd) Then Return + Dim ProjType As BWType = Map.refSupervisorManagerVM.CurrProd.nType + Dim BarList() As EgtBEAMWALL.Core.Bar + Dim TempBarList(Map.refMachGroupPanelVM.MachGroupVMList.Count - 1) As EgtBEAMWALL.Core.Bar + For PartIndex = 0 To Map.refMachGroupPanelVM.MachGroupVMList.Count - 1 + Dim CurrMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.MachGroupVMList(PartIndex) + Dim MachineName As String = "" + EgtGetMachGroupMachineName(CurrMachGroup.Id, MachineName) + Dim Bar As New EgtBEAMWALL.Core.Bar With {.nBarId = CurrMachGroup.Id, + .nProgramPage = ProjectType.PROD, + .nProjType = ProjType, + .bBarOk = True, + .nMachineName = MachineName} + Select Case CurrMachGroup.nGlobalState + Case Core.CalcStates.OK, Core.CalcStates.INFO + Bar.nCmdType = CalcIntegration.CmdType.GENERATE + Case Else + Dim sMachGroupFilePath As String = Map.refSupervisorManagerVM.CurrProd.sProdDirPath & "\" & CurrMachGroup.Name.ToString() & ".ori.bwe" + If File.Exists(sMachGroupFilePath) Then File.Delete(sMachGroupFilePath) + Bar.nCmdType = CalcIntegration.CmdType.CHECKGEN + End Select + TempBarList(PartIndex) = Bar + Next + BarList = TempBarList + ' disabilito interfaccia + Map.refProjectVM.ManageIsEnabled(False) + ' lancio calcolo + EgtBEAMWALL.Core.CalcIntegration.Run(BarList, Map.refSupervisorManagerVM.CurrProd.sProdDirPath, AddressOf ManageCalc) + End Sub + +#End Region ' VerifyAll + +#Region "Simulate" + + ''' + ''' Returns a command that do Open. + ''' + Public ReadOnly Property Simulate_Command As ICommand + Get + If m_cmdSimulate Is Nothing Then + m_cmdSimulate = New Command(AddressOf Simulate) + End If + Return m_cmdSimulate + End Get + End Property + + ''' + ''' Execute the Open. This method is invoked by the OpenCommand. + ''' + Friend Sub Simulate() + If IsNothing(Map.refSupervisorManagerVM.CurrProd) Then Return + Dim ProjType As BWType = Map.refSupervisorManagerVM.CurrProd.nType + Dim BarList() As EgtBEAMWALL.Core.Bar + Dim SelMachGroup As MyMachGroupVM = Map.refSupervisorMachGroupPanelVM.SelectedMachGroup + If Not IsNothing(SelMachGroup) Then + Dim TempBarList(0) As EgtBEAMWALL.Core.Bar + Dim MachineName As String = "" + EgtGetMachGroupMachineName(SelMachGroup.Id, MachineName) + Dim Bar As New EgtBEAMWALL.Core.Bar With {.nBarId = SelMachGroup.Id, + .nProgramPage = ProjectType.PROD, + .nProjType = ProjType, + .bBarOk = True, + .nMachineName = MachineName, + .nCmdType = CalcIntegration.CmdType.SIMULATE} + If SelMachGroup.nGlobalState <> Core.CalcStates.OK Then + Dim sMachGroupFilePath As String = Map.refSupervisorManagerVM.CurrProd.sProdDirPath & "\" & SelMachGroup.Name.ToString() & ".ori.bwe" + If File.Exists(sMachGroupFilePath) Then File.Delete(sMachGroupFilePath) + End If + TempBarList(0) = Bar + BarList = TempBarList + Else + Return + End If + ' disabilito interfaccia + Map.refProjectVM.ManageIsEnabled(False) + ' lancio simulazione + EgtBEAMWALL.Core.CalcIntegration.Run(BarList, Map.refSupervisorManagerVM.CurrProd.sProdDirPath, AddressOf ManageCalc) + End Sub + +#End Region ' Simulate + +#End Region ' COMMANDS + +End Class diff --git a/EgtBEAMWALL.Supervisor/CALCPanel/CalcPanelV.xaml b/EgtBEAMWALL.Supervisor/CALCPanel/CalcPanelV.xaml new file mode 100644 index 00000000..b205da60 --- /dev/null +++ b/EgtBEAMWALL.Supervisor/CALCPanel/CalcPanelV.xaml @@ -0,0 +1,36 @@ + + + + + + diff --git a/EgtBEAMWALL.Supervisor/CALCPanel/CalcPanelV.xaml.vb b/EgtBEAMWALL.Supervisor/CALCPanel/CalcPanelV.xaml.vb new file mode 100644 index 00000000..d2b5fc77 --- /dev/null +++ b/EgtBEAMWALL.Supervisor/CALCPanel/CalcPanelV.xaml.vb @@ -0,0 +1,3 @@ +Public Class CalcPanelV + +End Class diff --git a/EgtBEAMWALL.Supervisor/ConfigurationPage/ConfigurationPageV.xaml b/EgtBEAMWALL.Supervisor/ConfigurationPage/ConfigurationPageV.xaml new file mode 100644 index 00000000..f96cb6fd --- /dev/null +++ b/EgtBEAMWALL.Supervisor/ConfigurationPage/ConfigurationPageV.xaml @@ -0,0 +1,273 @@ + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Supervisor/ConfigurationPage/ConfigurationPageV.xaml.vb b/EgtBEAMWALL.Supervisor/ConfigurationPage/ConfigurationPageV.xaml.vb new file mode 100644 index 00000000..b380aec2 --- /dev/null +++ b/EgtBEAMWALL.Supervisor/ConfigurationPage/ConfigurationPageV.xaml.vb @@ -0,0 +1,5 @@ +Public Class ConfigurationPageV + Private Sub ScrollViewer_Scroll(sender As Object, e As Primitives.ScrollEventArgs) + + End Sub +End Class diff --git a/EgtBEAMWALL.Supervisor/ConfigurationPage/ConfigurationPageVM.vb b/EgtBEAMWALL.Supervisor/ConfigurationPage/ConfigurationPageVM.vb new file mode 100644 index 00000000..9a946401 --- /dev/null +++ b/EgtBEAMWALL.Supervisor/ConfigurationPage/ConfigurationPageVM.vb @@ -0,0 +1,976 @@ +Imports System.Collections.ObjectModel +Imports System.IO +Imports EgtUILib +Imports EgtWPFLib5 +Imports EgtBEAMWALL.Core + +Public Class ConfigurationPageVM + Inherits VMBase + + ' ' flag modifica parametri Macchina + ' Friend bModifyMachParam As Boolean + + ' ' Definizione comandi + ' Private m_cmdSave As ICommand + + ' Public ReadOnly Property MachinePanelVM As MachinePanelVM + ' Get + ' Return Map.refMachinePanelVM + ' End Get + ' End Property + + ' Private m_ConfigMachTableList As New ObservableCollection(Of MachTable) + ' Public Property ConfigMachTableList As ObservableCollection(Of MachTable) + ' Get + ' Return m_ConfigMachTableList + ' End Get + ' Set(value As ObservableCollection(Of MachTable)) + ' m_ConfigMachTableList = value + ' End Set + ' End Property + + ' Public ReadOnly Property Custom_Visibility As Visibility + ' Get + ' If QBTLParamVMList(0).bIsP Then + ' Return Visibility.Collapsed + ' Else + ' Return Visibility.Visible + ' End If + ' End Get + ' End Property + + ' ' lista dei parametri Q di un Process + ' Private m_QBTLParamVMList_View As CollectionView = Nothing + ' Protected m_QBTLParamVMList As New ObservableCollection(Of QBTLParamVM) + ' Public Property QBTLParamVMList As ObservableCollection(Of QBTLParamVM) + ' Get + ' Return m_QBTLParamVMList + ' End Get + ' Set(value As ObservableCollection(Of QBTLParamVM)) + ' m_QBTLParamVMList = value + ' End Set + ' End Property + + ' Private m_PRCList As New ObservableCollection(Of PRC) + ' Public ReadOnly Property PRCList As ObservableCollection(Of PRC) + ' Get + ' Return m_PRCList + ' End Get + ' End Property + + ' Private m_LanguageList As New ObservableCollection(Of Language) + ' Public ReadOnly Property LanguageList As ObservableCollection(Of Language) + ' Get + ' Return m_LanguageList + ' End Get + ' End Property + + ' Private m_UnitMeasureList As List(Of String) = New List(Of String)({"inch", "mm"}) + ' Public ReadOnly Property UnitMeasureList As List(Of String) + ' Get + ' Return m_UnitMeasureList + ' End Get + ' End Property + + ' Private m_SelectedLanguage As Language + ' Public Property SelectedLanguage As Language + ' Get + ' Return m_SelectedLanguage + ' End Get + ' Set(value As Language) + ' If value IsNot m_SelectedLanguage Then + ' m_SelectedLanguage = value + ' End If + ' End Set + ' End Property + + ' Public Property SelMeasureUnit As Integer + ' Get + ' Return If(EgtUiUnitsAreMM(), MeasureUnitOpt.MM, MeasureUnitOpt.INCH) + ' End Get + ' Set(value As Integer) + ' ' salvo unità di misura precedente + ' Dim PrevMeasureUnit As MeasureUnitOpt = If(EgtUiUnitsAreMM(), MeasureUnitOpt.MM, MeasureUnitOpt.INCH) + ' If value <> PrevMeasureUnit Then + ' ' cambio unità di misura + ' EgtSetUiUnits(DirectCast(value, MeasureUnitOpt) = MeasureUnitOpt.MM) + ' End If + ' End Set + ' End Property + + ' Private m_SectionTime As Double + ' Public Property SectionTime As String + ' Get + ' Return DoubleToString(m_SectionTime, 5) + ' End Get + ' Set(value As String) + ' Dim dVal As Double = 0 + ' If StringToDouble(value, dVal) AndAlso dVal > 0 Then + ' m_SectionTime = dVal + ' End If + ' End Set + ' End Property + + ' Private m_PartTime As Double + ' Public Property PartTime As String + ' Get + ' Return DoubleToString(m_PartTime, 5) + ' End Get + ' Set(value As String) + ' Dim dVal As Double = 0 + ' If StringToDouble(value, dVal) AndAlso dVal > 0 Then + ' m_PartTime = dVal + ' End If + ' End Set + ' End Property + + ' ' lista delle colonne con le relative proprietà della DataGrid + ' Private m_DGColumnsList_View As CollectionView = Nothing + ' Protected m_DGColumnsList As New ObservableCollection(Of IniDataGridColumn) + ' Public Property DGColumnsList As ObservableCollection(Of IniDataGridColumn) + ' Get + ' Return m_DGColumnsList + ' End Get + ' Set(value As ObservableCollection(Of IniDataGridColumn)) + ' m_DGColumnsList = value + ' End Set + ' End Property + + '#Region "Messages" + + ' Public ReadOnly Property L_Msg As String + ' Get + ' Return EgtMsg(61803) + ' End Get + ' End Property + + ' Public ReadOnly Property T_Msg As String + ' Get + ' Return EgtMsg(61804) + ' End Get + ' End Property + + ' Public ReadOnly Property PRC_Msg As String + ' Get + ' Return EgtMsg(61805) + ' End Get + ' End Property + + ' Public ReadOnly Property NAM_Msg As String + ' Get + ' Return EgtMsg(61608) + ' End Get + ' End Property + + ' Public ReadOnly Property Description_Msg As String + ' Get + ' Return EgtMsg(61603) + ' End Get + ' End Property + + ' Public ReadOnly Property Default_Msg As String + ' Get + ' Return EgtMsg(61802) + ' End Get + ' End Property + + ' Public ReadOnly Property Min_Msg As String + ' Get + ' Return EgtMsg(61616) + ' End Get + ' End Property + ' Public ReadOnly Property Max_Msg As String + ' Get + ' Return EgtMsg(61617) + ' End Get + ' End Property + ' Public ReadOnly Property CurrentLanguage_Msg As String + ' Get + ' Return EgtMsg(6501) + ' End Get + ' End Property + ' Public ReadOnly Property LanguageAdvert_Msg As String + ' Get + ' Return EgtMsg(6502) + ' End Get + ' End Property + ' Public ReadOnly Property MMUnits_Msg As String + ' Get + ' Return EgtMsg(6540) + ' End Get + ' End Property + ' Public ReadOnly Property Nesting_Msg As String + ' Get + ' Return EgtMsg(61829) + ' End Get + ' End Property + ' Public ReadOnly Property SectionTime_Msg As String + ' Get + ' Return EgtMsg(61806) + ' End Get + ' End Property + ' Public ReadOnly Property PartTime_Msg As String + ' Get + ' Return EgtMsg(61807) + ' End Get + ' End Property + + ' Public ReadOnly Property DisplayIndex_Msg As String + ' Get + ' Return EgtMsg(61842) + ' End Get + ' End Property + + ' Public ReadOnly Property ColumnName_Msg As String + ' Get + ' Return EgtMsg(61843) + ' End Get + ' End Property + + ' Public ReadOnly Property CanUserReorder_Msg As String + ' Get + ' Return EgtMsg(61844) + ' End Get + ' End Property + + ' Public ReadOnly Property CanUserResize_Msg As String + ' Get + ' Return EgtMsg(61845) + ' End Get + ' End Property + + ' Public ReadOnly Property CanUserSort_Msg As String + ' Get + ' Return EgtMsg(61846) + ' End Get + ' End Property + + ' Public ReadOnly Property IsReadOnly_Msg As String + ' Get + ' Return EgtMsg(61847) + ' End Get + ' End Property + + ' Public ReadOnly Property Visible_Msg As String + ' Get + ' Return EgtMsg(61848) + ' End Get + ' End Property + + '#End Region ' Messages + + '#Region "Constructor" + + ' Sub New() + ' ' imposto riferimento in Map + ' Map.SetRefConfigurationPageVM(Me) + ' ' Leggo nome lingua corrente + ' Dim sLanguage As String = String.Empty + ' GetMainPrivateProfileString(S_GENERAL, K_MESSAGES, "", sLanguage) + ' ' Leggo elenco lingue disponibili da file ini e imposto lingua corrente + ' Dim nIndex As Integer = 1 + ' While True + ' Dim ReadLanguage As Language = GetMainPrivateProfileLanguage(S_LANGUAGES, K_LANGUAGE & nIndex) + ' If IsNothing(ReadLanguage) Then Exit While + ' m_LanguageList.Add(ReadLanguage) + ' If String.Compare(ReadLanguage.Name, sLanguage, True) = 0 Then + ' m_SelectedLanguage = ReadLanguage + ' End If + ' nIndex += 1 + ' End While + ' ' Inizializzo la lingua corrente + ' m_SelectedLanguage = m_LanguageList(0) + ' Dim sMsgName As String = String.Empty + ' IniFile.GetMainPrivateProfileString(S_GENERAL, K_MESSAGES, "", sMsgName) + ' For Each Language In m_LanguageList + ' If Language.Name = sMsgName Then + ' m_SelectedLanguage = Language + ' Exit For + ' End If + ' Next + ' ' leggo SectionTime e PartTime + ' GetMainPrivateProfileString(S_NEST, K_SECTIONTIME, "", SectionTime) + ' GetMainPrivateProfileString(S_NEST, K_PARTTIME, "", PartTime) + ' ' assegno le liste dei parametri della macchina corrente alla ConfigMachTableList alla pagina di Configurazione + ' ConfigMachTableList = CurrentMachine.MachTableList + ' ' carico i parametri Q dei Process letti dall'ini + ' GetQParamsList() + ' ' carico la lista di tutti i parametri Q ciclando su ogni Process di PRCList + ' If Not IsNothing(QBTLParamVMList) Then + ' QBTLParamVMList.Clear() + ' End If + ' For Each PRCItem In PRCList + ' For Each QBTLParam In PRCItem.QBTLParamVMList + ' QBTLParamVMList.Add(QBTLParam) + ' Next + ' Next + ' NotifyPropertyChanged(NameOf(QBTLParamVMList)) + ' ' setto il grouping a 2 livelli (GRP e, sotto, PRC col nome completo) per la DataGrid + ' m_QBTLParamVMList_View = CollectionViewSource.GetDefaultView(m_QBTLParamVMList) + ' m_QBTLParamVMList_View.GroupDescriptions.Add(New PropertyGroupDescription(NameOf(QBTLParamVM.GroupType))) + ' m_QBTLParamVMList_View.GroupDescriptions.Add(New PropertyGroupDescription(NameOf(QBTLParamVM.ghDesc))) + ' ' carico la lista delle colonne delle DataGrid in ConfigurationPage + ' LoadConfigDGColumns() + ' ' setto il grouping ad 1 livello per la DataGrid + ' m_DGColumnsList_View = CollectionViewSource.GetDefaultView(m_DGColumnsList) + ' m_DGColumnsList_View.GroupDescriptions.Add(New PropertyGroupDescription(NameOf(IniDataGridColumn.ParentDataGridName))) + ' End Sub + + '#End Region ' Constructor + + '#Region "SaveCommand" + + ' ''' + ' ''' Returns a command that do Save. + ' ''' + ' Public ReadOnly Property SaveCommand As ICommand + ' Get + ' If m_cmdSave Is Nothing Then + ' m_cmdSave = New Command(AddressOf Save) + ' End If + ' Return m_cmdSave + ' End Get + ' End Property + + ' ''' + ' ''' Execute the Save. This method is invoked by the SaveCommand. + ' ''' + ' Public Sub Save() + ' WriteMachParams() + ' WriteProcessParams(PRCList.ToList()) + ' WriteDataGridColumns() + ' WriteMainPrivateProfileString(S_GENERAL, K_MESSAGES, m_SelectedLanguage.Name) + ' WriteMainPrivateProfileString(S_SCENE, K_MMUNITS, SelMeasureUnit.ToString()) + ' WriteMainPrivateProfileString(S_NEST, K_SECTIONTIME, DoubleToString(m_SectionTime, 5)) + ' WriteMainPrivateProfileString(S_NEST, K_PARTTIME, DoubleToString(m_PartTime, 5)) + ' End Sub + + '#End Region ' SaveCommand + + '#Region "Methods" + + ' ' funzione che scrive i parametri modificati sul file INI + ' Public Sub WriteMachParams() + ' For Each MachTableItem In ConfigMachTableList + ' For Each MachParamItem In MachTableItem.MachParamList + ' If MachParamItem.IsModified Then + ' Dim sMachParamType As String = String.Empty + ' Select Case MachParamItem.nType + ' Case MachParamType.DOUBLE_ + ' sMachParamType = "d" + ' Case MachParamType.STRING_ + ' sMachParamType = "s" + ' Case MachParamType.LENGTH + ' sMachParamType = "l" + ' End Select + ' Dim MachParamString As String = sMachParamType & "," & MachParamItem.sName & "," & MachParamItem.sValue & "," & MachParamItem.sDescription + ' Dim bOk = WriteMachPrivateProfileString(MachParamItem.nParentTable, MachParamItem.nParamIndex, MachParamString) + ' If Not bOk Then + ' MessageBox.Show(EgtMsg(61859), EgtMsg(30007)) + ' Return + ' End If + ' MachParamItem.IsModifiedReset() + ' End If + ' Next + ' Next + ' End Sub + + ' ' funzione che verifica la modifica dei valori in Configurazione e ne chiede il salvataggio + ' Friend Sub VerifyConfigPageModification() + ' ' Prima ciclo sui parametri Macchina + ' Dim bExitFor = False + ' For Each MachTableItem In ConfigMachTableList + ' For Each MachParamItem In MachTableItem.MachParamList + ' If MachParamItem.IsModified Then + ' If MessageBox.Show(EgtMsg(61860), "", MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then + ' ' scrivo i parametri Macchina + ' WriteMachParams() + ' Else + ' ' se da non salvare li resetto ed esco dai For + ' CreateMachParams() + ' bExitFor = True + ' Exit For + ' End If + ' End If + ' Next + ' If bExitFor Then Exit For + ' Next + ' ' Ora ciclo sui parametri Q + ' Dim bAskToSaveDefaultValues As Boolean = False + ' bExitFor = False + ' For Each PRCItem In PRCList + ' For Each QParam In PRCItem.QBTLParamVMList + ' If QParam.bIsModified Then + ' bAskToSaveDefaultValues = True + ' ' esco dai For + ' bExitFor = True + ' Exit For + ' End If + ' Next + ' If bExitFor Then Exit For + ' Next + ' ' se nel ciclo è stato trovato almeno un valore modificato chiedo il salvataggio + ' If bAskToSaveDefaultValues Then + ' If MessageBox.Show(EgtMsg(61861), "", MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then + ' ' se si è scelto di salvare i valori li scrivo + ' WriteProcessParams(PRCList.ToList()) + ' End If + ' ' in ogni caso ricarico i valori (in modo da resettare i flag di modifica) + ' GetQParamsList() + ' ' carico la lista di tutti i parametri Q ciclando su ogni Process di PRCList + ' If Not IsNothing(QBTLParamVMList) Then + ' QBTLParamVMList.Clear() + ' End If + ' For Each PRCItem In PRCList + ' For Each QBTLParam In PRCItem.QBTLParamVMList + ' QBTLParamVMList.Add(QBTLParam) + ' Next + ' Next + ' NotifyPropertyChanged(NameOf(QBTLParamVMList)) + ' End If + ' ' verifico se i valori delle colonne DataGrid sono stati modificati + ' For Each DGColumnItem In DGColumnsList + ' If DGColumnItem.IsModified Then + ' If MessageBox.Show(EgtMsg(61882), "", MessageBoxButton.YesNo, MessageBoxImage.Question) = MessageBoxResult.Yes Then + ' ' scrivo i valori delle colonne DataGrid modificate + ' WriteDataGridColumns() + ' Else + ' ' se da non salvare li resetto ed esco dai For + ' LoadConfigDGColumns() + ' Exit For + ' End If + ' End If + ' Next + ' End Sub + + ' ' funzione che verifica l'inserimento della password quando si edita un parametro Macchina + ' Friend Function VerifyConfigPagePassword() As Boolean + ' ' Display message, title, and default value. + ' Dim sPwdInput = InputBox("Inserire Password: ", "Richiesta Pwd") + ' ' Lettura PWD dall'INI e confronto + ' Dim sPwdIni As String = String.Empty + ' If GetMainPrivateProfileString(S_MACH, K_PASSWORD, "", sPwdIni) <> 0 Then + ' If sPwdIni = sPwdInput Then Return True + ' End If + ' Return False + ' End Function + + ' Public Sub GetQParamsList() + ' m_PRCList.Clear() + ' ' carico lista process + ' Dim TempPRCList As New ObservableCollection(Of Integer) + ' ' prima cerco i process L (GRPType = 0) + ' Dim GRPType As Integer = 0 + ' GetBeamPrivateProfileProcessList(GRPType, TempPRCList) + ' For Each PRC In TempPRCList + ' ' leggo gruppi + ' Dim GRPList As New ObservableCollection(Of Integer) + ' GetBeamPrivateProfileGRPList(GRPType, PRC, GRPList) + ' m_PRCList.Add(New PRC(If(GRPList.Count > 0, GRPList(0), GRPType), PRC, GetBeamPrivateProfileName(GRPType, PRC), CreateProcessParams(GRPType, PRC, False))) + ' Next + ' ' ora cerco i process T (GRPType = 1) + ' GRPType = 1 + ' GetBeamPrivateProfileProcessList(GRPType, TempPRCList) + ' For Each PRC In TempPRCList + ' ' leggo gruppi + ' Dim GRPList As New ObservableCollection(Of Integer) + ' GetBeamPrivateProfileGRPList(GRPType, PRC, GRPList) + ' m_PRCList.Add(New PRC(If(GRPList.Count > 0, GRPList(0), GRPType), PRC, GetBeamPrivateProfileName(GRPType, PRC), CreateProcessParams(GRPType, PRC, False))) + ' Next + ' End Sub + + ' ' funzione che crea l'elenco dei parametri P o Q di un Process + ' Public Function CreateProcessParams(GRPType As Integer, PRC As Integer, IsP As Boolean) + ' Dim ParamIndex As Integer = 1 + ' Dim TempList As New List(Of QBTLParamVM) + ' Dim NewBTLParam As BTLParamM = Nothing + ' ' leggo tutti i parametri P o Q del Process + ' ParamIndex = 1 + ' TempList = New List(Of QBTLParamVM) + ' While BTLIniFile.GetBeamPrivateProfileParam(GRPType, PRC, IsP, ParamIndex, Nothing, NewBTLParam) + ' TempList.Add(New QBTLParamVM(NewBTLParam, GRPType, PRC)) + ' ParamIndex += 1 + ' End While + ' Return TempList + ' End Function + + ' ' funzione che scrive l'elenco dei parametri P o Q di un Process + ' Public Sub WriteProcessParams(PRCList As List(Of PRC)) + ' For Each PRCItem In PRCList + ' Dim nPRCParamIndex As Integer = 1 + ' For Each PRCParam In PRCItem.QBTLParamVMList + ' If PRCParam.bIsModified Then + ' ' costruisco la stringa da scrivere nel parametro + ' Dim sType As String = "" + ' If PRCParam.nType = 1 Then + ' sType = "d" + ' ElseIf PRCParam.nType = 4 Then + ' sType = "l" + ' End If + ' Dim sPRCParam As String = sType & "," & If(PRCParam.bIsP, "P", "Q") & PRCParam.nId.ToString("D2") & "," & PRCParam.sMin & "," & PRCParam.sMax & "," & PRCParam.sDefault & "," & PRCParam.sDescription + ' WritePrivateProfileString(PRCItem.nGRP & "." & PRCItem.nPRC, If(PRCParam.bIsP, "P", "Q") & nPRCParamIndex, sPRCParam, m_sBTLIniFile) + ' End If + ' nPRCParamIndex += 1 + ' Next + ' Next + ' End Sub + + ' ' funzione che carica la DataGrid di configurazione delle colonne delle EgtDataGrid + ' Public Sub LoadConfigDGColumns() + ' DGColumnsList.Clear() + ' GetPrivateProfileColumns(S_FEATURELIST, DGColumnsList) + ' GetPrivateProfileColumns(S_OPENPROJFILEDLG_PROJ, DGColumnsList) + ' GetPrivateProfileColumns(S_OPENPROJFILEDLG_PROD, DGColumnsList) + ' GetPrivateProfileColumns(S_RAWPARTLIST_BEAM, DGColumnsList) + ' GetPrivateProfileColumns(S_RAWPARTLIST_WALL, DGColumnsList) + ' GetPrivateProfileColumns(S_PARTINRAWPARTLIST_BEAM, DGColumnsList) + ' GetPrivateProfileColumns(S_PARTINRAWPARTLIST_WALL, DGColumnsList) + ' End Sub + + ' ' funzione per calcolare e scrivere la stringhe dei parametri delle colonne relative ad una ParentDataGridName nell'INI + ' Public Sub SaveDataGridColumns(ParentDataGridName As String, DGColumnsList As ObservableCollection(Of IniDataGridColumn)) + ' For Each ColumnItem In DGColumnsList + ' If ColumnItem.ParentDataGridName = ParentDataGridName Then + ' Dim sColumnParams = String.Empty + ' sColumnParams = ColumnItem.Name & "," & If(ColumnItem.CanUserReorder, 1, 0) & "," & If(ColumnItem.CanUserResize, 1, 0) & "," & + ' If(ColumnItem.CanUserSort, 1, 0) & "," & If(ColumnItem.IsReadOnly, 1, 0) & "," & DoubleToString(ColumnItem.Width.Value, 6) & "," & + ' ColumnItem.Width.UnitType & "," & If(ColumnItem.Visible, 1, 0) & "," & If(ColumnItem.CanUserEditVisible, 1, 0) + ' WriteColumnPrivateProfileParam(ParentDataGridName, ColumnItem.m_DisplayIndex, sColumnParams) + ' End If + ' Next + ' End Sub + + ' ' funzione che scrive i valori delle proprietà delle colonne customizzate delle EgtDataGrid nell'INI + ' Public Sub WriteDataGridColumns() + ' SaveDataGridColumns(S_FEATURELIST, DGColumnsList) + ' SaveDataGridColumns(S_OPENPROJFILEDLG_PROJ, DGColumnsList) + ' SaveDataGridColumns(S_OPENPROJFILEDLG_PROD, DGColumnsList) + ' SaveDataGridColumns(S_RAWPARTLIST_BEAM, DGColumnsList) + ' SaveDataGridColumns(S_RAWPARTLIST_WALL, DGColumnsList) + ' SaveDataGridColumns(S_PARTINRAWPARTLIST_BEAM, DGColumnsList) + ' SaveDataGridColumns(S_PARTINRAWPARTLIST_WALL, DGColumnsList) + ' For Each DGColumnItem In DGColumnsList + ' DGColumnItem.IsModifiedReset() + ' Next + ' End Sub + + '#End Region ' Methods + +End Class + +'Public Class MachParam +' Inherits VMBase + +' ' table a cui appartiene il parametro +' Private m_nParentTable As Integer +' Friend ReadOnly Property nParentTable As Integer +' Get +' Return m_nParentTable +' End Get +' End Property + +' ' indice del parametro +' Private m_nParamIndex As Integer +' Friend ReadOnly Property nParamIndex As Integer +' Get +' Return m_nParamIndex +' End Get +' End Property + +' ' tipo della variabile +' Private m_nType As MachParamType +' Friend ReadOnly Property nType As MachParamType +' Get +' Return m_nType +' End Get +' End Property + +' ' parametri da struttura +' Private m_sName As String +' Public Property sName As String +' Get +' Return m_sName +' End Get +' Set(value As String) +' m_sName = value +' End Set +' End Property + +' ' parametri da geometria +' Private m_IsModifiedValue As Boolean = False +' Private m_dValue As Double +' Private m_sValue As String +' Public Property sValue As String +' Get +' Select Case nType +' Case MachParamType.DOUBLE_ +' Return DoubleToString(m_dValue, 3) +' Case MachParamType.LENGTH +' Return LenToString(m_dValue, 3) +' Case Else ' stringhe +' Return m_sValue +' End Select +' Return If(nType = MachParamType.LENGTH, LenToString(m_dValue, 3), DoubleToString(m_dValue, 3)) +' End Get +' Set(value As String) +' Dim dNewValue As Double +' ' verifico se valore immesso è diverso dall'originale +' If nParentTable > 0 Then +' Dim sOrigValue As String = String.Empty +' Dim dOrigValue As Double +' MachParamIniFile.GetMachPrivateProfileParamValue(nParentTable, nParamIndex, sOrigValue) +' ' trasformo valori +' Select Case nType +' Case MachParamType.DOUBLE_ +' StringToDouble(value, dNewValue) +' StringToDouble(sOrigValue, dOrigValue) +' Case MachParamType.LENGTH +' StringToLen(value, dNewValue) +' StringToLen(sOrigValue, dOrigValue) +' Case Else +' ' per string non faccio nulla +' End Select +' m_IsModifiedValue = dNewValue <> dOrigValue +' End If +' ' se valore immesso è diverso e password non inserita +' If m_IsModifiedValue AndAlso Not Map.refConfigurationPageVM.bModifyMachParam Then +' Map.refConfigurationPageVM.bModifyMachParam = Map.refConfigurationPageVM.VerifyConfigPagePassword() +' If Not Map.refConfigurationPageVM.bModifyMachParam Then +' NotifyPropertyChanged("sValue") +' m_IsModifiedValue = False +' Return +' End If +' End If + +' Select Case nType +' Case MachParamType.DOUBLE_, MachParamType.LENGTH +' UpdateParamValue(dNewValue, "") +' Case Else +' UpdateParamValue(0, value) +' End Select +' End Set +' End Property +' Public Property dValue As Double +' Get +' Return m_dValue +' End Get +' Set(value As Double) +' m_dValue = value +' NotifyPropertyChanged("sValue") +' End Set +' End Property + +' ' descrizione del parametro +' Private m_sDescription As String +' Public Property sDescription As String +' Get +' Return m_sDescription +' End Get +' Set(value As String) +' m_sDescription = value +' End Set +' End Property + +' Private Sub StdInit(nParentTable As Integer, nParamIndex As Integer, Type As MachParamType, sName As String, sDescription As String) +' m_nParentTable = nParentTable +' m_nParamIndex = nParamIndex +' m_nType = Type +' m_sName = sName +' m_sDescription = MsgToString(sDescription) +' End Sub + +' ' new per double e length +' Sub New(nParentTable As Integer, nParamIndex As Integer, nType As MachParamType, sParamName As String, dValue As Double, sDescription As String) +' StdInit(nParentTable, nParamIndex, nType, sParamName, sDescription) +' m_dValue = dValue 'sValue = DoubleToString(dValue, 3) +' End Sub + +' ' new per stringhe +' Sub New(nParentTable As Integer, nParamIndex As Integer, nType As MachParamType, sParamName As String, sDescription As String) +' StdInit(nParentTable, nParamIndex, nType, sParamName, sDescription) +' End Sub + +' ' new per parametro vuoto +' Sub New(nType As MachParamType, nParamIndex As Integer, sParamName As String) +' StdInit(Nothing, nParamIndex, nType, sParamName, "") +' End Sub + +' Friend Sub UpdateParamValue(dNewValue As Double, sNewValue As String, Optional bDraw As Boolean = True) +' Select Case nType +' Case MachParamType.DOUBLE_, MachParamType.LENGTH +' m_dValue = dNewValue +' Case MachParamType.STRING_ +' m_sValue = sNewValue +' End Select +' End Sub + +' Public ReadOnly Property IsModified() As Boolean +' Get +' Return m_IsModifiedValue +' End Get +' End Property + +' Public Sub IsModifiedReset() +' m_IsModifiedValue = False +' End Sub + +'End Class + +'Public Class MachTable +' Inherits VMBase + +' ' nome della table +' Private m_sName As String +' Public Property sName As String +' Get +' Return m_sName +' End Get +' Set(value As String) +' m_sName = value +' End Set +' End Property + +' Private m_MachParamList As New ObservableCollection(Of MachParam) +' Public Property MachParamList As ObservableCollection(Of MachParam) +' Get +' Return m_MachParamList +' End Get +' Set(value As ObservableCollection(Of MachParam)) +' m_MachParamList = value +' End Set +' End Property + +' Sub New(Name As String, ParamList As ObservableCollection(Of MachParam)) +' sName = Name +' MachParamList = ParamList +' End Sub + +'End Class + +'Public Class IniDataGridColumn + +' Private Property m_ParentDataGridName As String +' Public Property ParentDataGridName As String +' Get +' Return m_ParentDataGridName +' End Get +' Set(value As String) +' m_ParentDataGridName = value +' End Set +' End Property + +' Private Property m_Name As String +' Public Property Name As String +' Get +' Return m_Name +' End Get +' Set(value As String) +' m_Name = value +' End Set +' End Property + +' Private Property m_Width As DataGridLength +' Public Property Width As DataGridLength +' Get +' Return m_Width +' End Get +' Set(value As DataGridLength) +' m_Width = value +' End Set +' End Property + +' Private m_IsModifiedDisplayIndex +' Friend Property m_DisplayIndex As Integer +' Public Property DisplayIndex As Integer +' Get +' Return If(Visible, m_DisplayIndex, -1) +' End Get +' Set(value As Integer) +' m_DisplayIndex = value +' m_IsModifiedDisplayIndex = (m_Name <> +' GetPrivateProfileColumnProperty(ParentDataGridName, Map.refConfigurationPageVM.DGColumnsList, m_DisplayIndex, EgtDGColumnProperty.NAME)) +' ' se DisplayIndex viene settato ad un valore che corrisponde a quello che aveva inizialmente aggiorno gli IsModified +' ' delle altre proprietà utilizzando il DisplayIndex attuale +' If Not m_IsModifiedDisplayIndex Then +' m_IsModifiedIsReadOnly = (m_IsReadOnly <> +' GetPrivateProfileColumnProperty(ParentDataGridName, Map.refConfigurationPageVM.DGColumnsList, m_DisplayIndex, EgtDGColumnProperty.ISREADONLY)) +' m_IsModifiedCanUserReorder = (m_CanUserReorder <> +' GetPrivateProfileColumnProperty(ParentDataGridName, Map.refConfigurationPageVM.DGColumnsList, m_DisplayIndex, EgtDGColumnProperty.REORDER)) +' m_IsModifiedCanUserResize = (m_CanUserResize <> +' GetPrivateProfileColumnProperty(ParentDataGridName, Map.refConfigurationPageVM.DGColumnsList, m_DisplayIndex, EgtDGColumnProperty.RESIZE)) +' m_IsModifiedCanUserSort = (m_CanUserSort <> +' GetPrivateProfileColumnProperty(ParentDataGridName, Map.refConfigurationPageVM.DGColumnsList, m_DisplayIndex, EgtDGColumnProperty.SORT)) +' m_IsModifiedVisible = (m_Visible <> +' GetPrivateProfileColumnProperty(ParentDataGridName, Map.refConfigurationPageVM.DGColumnsList, m_DisplayIndex, EgtDGColumnProperty.VISIBLE)) +' End If +' End Set +' End Property + +' Private m_IsModifiedIsReadOnly As Boolean = False +' Private Property m_IsReadOnly As Boolean = True +' Public Property IsReadOnly As Boolean +' Get +' Return m_IsReadOnly +' End Get +' Set(value As Boolean) +' m_IsReadOnly = value +' m_IsModifiedIsReadOnly = (m_IsReadOnly <> +' GetPrivateProfileColumnProperty(ParentDataGridName, Map.refConfigurationPageVM.DGColumnsList, m_DisplayIndex, EgtDGColumnProperty.ISREADONLY)) +' End Set +' End Property + +' Private m_IsModifiedCanUserReorder As Boolean = False +' Private m_CanUserReorder As Boolean +' Public Property CanUserReorder As Boolean +' Get +' Return m_CanUserReorder +' End Get +' Set(value As Boolean) +' m_CanUserReorder = value +' m_IsModifiedCanUserReorder = (m_CanUserReorder <> +' GetPrivateProfileColumnProperty(ParentDataGridName, Map.refConfigurationPageVM.DGColumnsList, m_DisplayIndex, EgtDGColumnProperty.REORDER)) +' End Set +' End Property + +' Private m_IsModifiedCanUserResize As Boolean = False +' Private m_CanUserResize As Boolean +' Public Property CanUserResize As Boolean +' Get +' Return m_CanUserResize +' End Get +' Set(value As Boolean) +' m_CanUserResize = value +' m_IsModifiedCanUserResize = (m_CanUserResize <> +' GetPrivateProfileColumnProperty(ParentDataGridName, Map.refConfigurationPageVM.DGColumnsList, m_DisplayIndex, EgtDGColumnProperty.RESIZE)) +' End Set +' End Property + +' Private m_IsModifiedCanUserSort As Boolean = False +' Private m_CanUserSort As Boolean +' Public Property CanUserSort As Boolean +' Get +' Return m_CanUserSort +' End Get +' Set(value As Boolean) +' m_CanUserSort = value +' m_IsModifiedCanUserSort = (m_CanUserSort <> +' GetPrivateProfileColumnProperty(ParentDataGridName, Map.refConfigurationPageVM.DGColumnsList, m_DisplayIndex, EgtDGColumnProperty.SORT)) +' End Set +' End Property + +' Private m_IsModifiedVisible As Boolean = False +' Private m_Visible As Boolean +' Public Property Visible As Boolean +' Get +' Return m_Visible +' End Get +' Set(value As Boolean) +' m_Visible = value +' ' Utilizzo OldDGIndex e NewDGIndex per muovere la Column tra il gruppo dei Visible (in alto) o il gruppo +' ' dei non Visible (in basso): in ambo i casi verrà sempre spostata in mezzo ai due raggruppamenti +' Dim OldDGIndex As Integer = Map.refConfigurationPageVM.DGColumnsList.IndexOf(Me) +' If value Then +' Dim NewDGIndex As Integer = Map.refConfigurationPageVM.DGColumnsList.IndexOf(Map.refConfigurationPageVM.DGColumnsList.FirstOrDefault( +' Function(x) x.ParentDataGridName = ParentDataGridName AndAlso +' x.Visible = False)) +' ' se NewDGIndex = -1 (ovvero ho settato l'ultima Column rimasta non Visible a Visible) oppure +' ' se il nuovo indice è subito dopo il vecchio non la sposto altrimenti viene spostata in maniera sbagliata +' If NewDGIndex <> -1 AndAlso NewDGIndex <> OldDGIndex + 1 Then Map.refConfigurationPageVM.DGColumnsList.Move(OldDGIndex, NewDGIndex) +' Else +' Dim NewDGIndex As Integer = Map.refConfigurationPageVM.DGColumnsList.IndexOf(Map.refConfigurationPageVM.DGColumnsList.FirstOrDefault( +' Function(x) x.ParentDataGridName = ParentDataGridName AndAlso +' x.Visible = False AndAlso +' x.Name <> Name)) +' ' se NewDGIndex = -1 vuol dire che erano tutte settate a Visible perciò devo calcolare l'indice +' ' dell'ultima Column con quel ParentDataGridName e spostarlo lì +' If NewDGIndex = -1 Then +' Dim FirstIndex As Integer = Map.refConfigurationPageVM.DGColumnsList.IndexOf(Map.refConfigurationPageVM.DGColumnsList.FirstOrDefault( +' Function(x) x.ParentDataGridName = ParentDataGridName)) +' Dim LastIndex = FirstIndex +' While LastIndex < Map.refConfigurationPageVM.DGColumnsList.Count AndAlso Map.refConfigurationPageVM.DGColumnsList(LastIndex).ParentDataGridName = ParentDataGridName +' LastIndex += 1 +' End While +' NewDGIndex = LastIndex +' End If +' Map.refConfigurationPageVM.DGColumnsList.Move(OldDGIndex, NewDGIndex - 1) +' End If +' ' aggiorno i DisplayIndex di ciascuna Column della ParentDataGridName in questione +' Dim index = 0 +' For Each DGColumnItem In Map.refConfigurationPageVM.DGColumnsList +' If DGColumnItem.ParentDataGridName = ParentDataGridName Then +' DGColumnItem.DisplayIndex = index +' index += 1 +' End If +' Next +' ' uso il Move col medesimo valore per i 2 argomenti per refreshare i DisplayIndex delle Column +' ' della ParentDataGridName in questione appena riordinate +' For index = 0 To Map.refConfigurationPageVM.DGColumnsList.Count - 1 +' If Map.refConfigurationPageVM.DGColumnsList(index).ParentDataGridName = ParentDataGridName Then +' Map.refConfigurationPageVM.DGColumnsList.Move(index, index) +' End If +' Next +' ' setto se il valore è stato modificato, a partire dalla verifica che il Nome e DisplayIndex combacino (altrimenti è per forza modificato) +' m_IsModifiedVisible = (m_Name <> +' GetPrivateProfileColumnProperty(ParentDataGridName, Map.refConfigurationPageVM.DGColumnsList, m_DisplayIndex, EgtDGColumnProperty.NAME)) OrElse +' (If(m_Visible, 1, 0) <> +' GetPrivateProfileColumnProperty(ParentDataGridName, Map.refConfigurationPageVM.DGColumnsList, m_DisplayIndex, EgtDGColumnProperty.VISIBLE)) +' End Set +' End Property + +' Private m_CanUserEditVisible As Boolean +' Public Property CanUserEditVisible As Boolean +' Get +' Return m_CanUserEditVisible +' End Get +' Set(value As Boolean) +' m_CanUserEditVisible = value +' End Set +' End Property + +' Public ReadOnly Property IsModified() As Boolean +' Get +' Return m_IsModifiedDisplayIndex OrElse +' m_IsModifiedIsReadOnly OrElse +' m_IsModifiedCanUserReorder OrElse +' m_IsModifiedCanUserResize OrElse +' m_IsModifiedCanUserSort OrElse +' m_IsModifiedVisible +' End Get +' End Property + +' Public Sub IsModifiedReset() +' m_IsModifiedDisplayIndex = False +' m_IsModifiedIsReadOnly = False +' m_IsModifiedCanUserReorder = False +' m_IsModifiedCanUserResize = False +' m_IsModifiedCanUserSort = False +' m_IsModifiedVisible = False +' End Sub + +' Sub New(sName As String) +' m_Name = sName +' End Sub + +' Sub New(sParentDG As String, nDisplayIndex As Integer, sName As String, bCanUserReorder As Boolean, bCanUserResize As Boolean, bCanUserSort As Boolean, bIsReadOnly As Boolean, Width As DataGridLength, bVisible As Boolean, bCanUserEditVisible As Boolean) +' m_ParentDataGridName = sParentDG +' m_DisplayIndex = nDisplayIndex +' m_Name = sName +' m_CanUserReorder = bCanUserReorder +' m_CanUserResize = bCanUserResize +' m_CanUserSort = bCanUserSort +' m_IsReadOnly = bIsReadOnly +' m_Width = Width +' m_Visible = bVisible +' m_CanUserEditVisible = bCanUserEditVisible +' End Sub + +'End Class + +'' Tipo parametro nel file di configurazione Macchina +'Public Enum MachParamType As Integer +' DOUBLE_ = 1 +' STRING_ = 2 +' COMBO = 3 +' LENGTH = 4 +' CHECKBOX = 5 +'End Enum diff --git a/EgtBEAMWALL.Supervisor/ConfigurationPage/DGColumnsListV.xaml b/EgtBEAMWALL.Supervisor/ConfigurationPage/DGColumnsListV.xaml new file mode 100644 index 00000000..3c6d3ce0 --- /dev/null +++ b/EgtBEAMWALL.Supervisor/ConfigurationPage/DGColumnsListV.xaml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Supervisor/ConfigurationPage/DGColumnsListV.xaml.vb b/EgtBEAMWALL.Supervisor/ConfigurationPage/DGColumnsListV.xaml.vb new file mode 100644 index 00000000..c06af363 --- /dev/null +++ b/EgtBEAMWALL.Supervisor/ConfigurationPage/DGColumnsListV.xaml.vb @@ -0,0 +1,3 @@ +Public Class DGColumnsListV + +End Class diff --git a/EgtBEAMWALL.Supervisor/EgtBEAMWALL.Supervisor.vbproj b/EgtBEAMWALL.Supervisor/EgtBEAMWALL.Supervisor.vbproj index eea3aa54..e726b365 100644 --- a/EgtBEAMWALL.Supervisor/EgtBEAMWALL.Supervisor.vbproj +++ b/EgtBEAMWALL.Supervisor/EgtBEAMWALL.Supervisor.vbproj @@ -217,7 +217,18 @@ AboutBoxV.xaml + + CalcPanelV.xaml + + + + ConfigurationPageV.xaml + + + + DGColumnsListV.xaml + @@ -225,6 +236,9 @@ + + FeatureInPartInRawPartListV.xaml + LeftPanelV.xaml @@ -251,6 +265,10 @@ + + MainMenuV.xaml + + @@ -269,6 +287,10 @@ ShowPanelV.xaml + + + StatusBarV.xaml + SupervisorManagerV.xaml @@ -291,6 +313,22 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + MSBuild:Compile Designer @@ -311,6 +349,10 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + MSBuild:Compile Designer @@ -339,6 +381,10 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + MSBuild:Compile Designer diff --git a/EgtBEAMWALL.Supervisor/LeftPanel/FeatureInPartInRawPartListV.xaml b/EgtBEAMWALL.Supervisor/LeftPanel/FeatureInPartInRawPartListV.xaml new file mode 100644 index 00000000..e21e134c --- /dev/null +++ b/EgtBEAMWALL.Supervisor/LeftPanel/FeatureInPartInRawPartListV.xaml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/EgtBEAMWALL.Supervisor/LeftPanel/FeatureInPartInRawPartListV.xaml.vb b/EgtBEAMWALL.Supervisor/LeftPanel/FeatureInPartInRawPartListV.xaml.vb new file mode 100644 index 00000000..3374296b --- /dev/null +++ b/EgtBEAMWALL.Supervisor/LeftPanel/FeatureInPartInRawPartListV.xaml.vb @@ -0,0 +1,3 @@ +Public Class FeatureInPartInRawPartListV + +End Class diff --git a/EgtBEAMWALL.Supervisor/LeftPanel/FeatureInPartInRawPartListVM.vb b/EgtBEAMWALL.Supervisor/LeftPanel/FeatureInPartInRawPartListVM.vb new file mode 100644 index 00000000..a858aeda --- /dev/null +++ b/EgtBEAMWALL.Supervisor/LeftPanel/FeatureInPartInRawPartListVM.vb @@ -0,0 +1,21 @@ +Imports EgtUILib + +Public Class FeatureInPartInRawPartListVM + +#Region "Messages" + + Public ReadOnly Property Description_Msg As String + Get + Return EgtMsg(61603) + End Get + End Property + + Public ReadOnly Property DO_Msg As String + Get + Return EgtMsg(61610) + End Get + End Property + +#End Region ' Messages + +End Class diff --git a/EgtBEAMWALL.Supervisor/LeftPanel/LeftPanelV.xaml b/EgtBEAMWALL.Supervisor/LeftPanel/LeftPanelV.xaml index e010a6dd..572897ff 100644 --- a/EgtBEAMWALL.Supervisor/LeftPanel/LeftPanelV.xaml +++ b/EgtBEAMWALL.Supervisor/LeftPanel/LeftPanelV.xaml @@ -10,6 +10,7 @@ + @@ -32,24 +33,35 @@ - - diff --git a/EgtBEAMWALL.ViewerOptimizer/EgtBEAMWALL.ViewerOptimizer.vbproj b/EgtBEAMWALL.ViewerOptimizer/EgtBEAMWALL.ViewerOptimizer.vbproj index 4dc9a7cd..bc11ee72 100644 --- a/EgtBEAMWALL.ViewerOptimizer/EgtBEAMWALL.ViewerOptimizer.vbproj +++ b/EgtBEAMWALL.ViewerOptimizer/EgtBEAMWALL.ViewerOptimizer.vbproj @@ -115,8 +115,9 @@ ..\packages\EntityFramework.6.4.4\lib\net45\EntityFramework.SqlServer.dll - - ..\..\..\EgtProg\DllD32\Ionic.Zip.dll + + False + ..\..\..\EgtProg\EgtBEAMWALL\Ionic.Zip.dll ..\packages\MySql.Data.6.10.9\lib\net40\MySql.Data.dll diff --git a/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/InstrumentPanelV.xaml b/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/InstrumentPanelV.xaml index 98269b01..efc4ec98 100644 --- a/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/InstrumentPanelV.xaml +++ b/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/InstrumentPanelV.xaml @@ -31,25 +31,6 @@ - - - diff --git a/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/MyInstrumentPanelVM.vb b/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/MyInstrumentPanelVM.vb index da44dbdc..043f73a2 100644 --- a/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/MyInstrumentPanelVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/InstrumentPanel/MyInstrumentPanelVM.vb @@ -64,8 +64,6 @@ Public Class MyInstrumentPanelVM ' Definizione comandi Private m_cmdData As ICommand Private m_cmdChangeParameter As ICommand - Private m_cmdVerify As ICommand - Private m_cmdSimulate As ICommand Private m_cmdStatistics As ICommand #Region "Messages" @@ -76,18 +74,6 @@ Public Class MyInstrumentPanelVM End Get End Property - Public ReadOnly Property Verify_ToolTip As String - Get - Return EgtMsg(61901) - End Get - End Property - - Public ReadOnly Property Simulate_ToolTip As String - Get - Return EgtMsg(61902) - End Get - End Property - Public ReadOnly Property Statistics_Msg As String Get Return EgtMsg(61923) @@ -245,205 +231,6 @@ Public Class MyInstrumentPanelVM #End Region ' ChangeParameter -#Region "Verify" - - ''' - ''' Returns a command that do Open. - ''' - Public ReadOnly Property Verify_Command As ICommand - Get - If m_cmdVerify Is Nothing Then - m_cmdVerify = New Command(AddressOf Verify) - End If - Return m_cmdVerify - End Get - End Property - - ''' - ''' Execute the Open. This method is invoked by the OpenCommand. - ''' - Friend Sub Verify() - If (Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso (IsNothing(Map.refProjManagerVM.CurrProj) OrElse IsNothing(Map.refProjectVM.BTLStructureVM)) OrElse - (Map.refMainMenuVM.SelPage = Pages.MACHINING AndAlso (IsNothing(Map.refProdManagerVM.CurrProd) OrElse IsNothing(Map.refProjectVM.MachGroupPanelVM)))) Then Return - Dim Calc As New CalcIntegration - Dim BarList() As CalcIntegration.Bar - If Map.refMainMenuVM.SelPage = Pages.VIEW Then - If ((Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift) Then - Dim TempBarList As New List(Of CalcIntegration.Bar) - For PartIndex = 0 To Map.refProjectVM.BTLStructureVM.BTLPartVMList.Count - 1 - Dim CurrPart As BTLPartVM = Map.refProjectVM.BTLStructureVM.BTLPartVMList(PartIndex) - If Not CurrPart.bDO Then Continue For - Dim Bar As New CalcIntegration.Bar With {.nBarId = CurrPart.nPartId, - .nBarType = ProjectType.PROJ, - .bBarOk = True} - Select Case CurrPart.nGlobalState - Case Core.CalcStates.OK, CalcStates.INFO - Bar.nCmdType = CalcIntegration.CmdType.GENERATE - Case Else - Dim sBTLPartFilePath As String = Map.refProjManagerVM.CurrProj.sProjDirPath & "\" & CurrPart.nPDN.ToString() & ".ori.bwe" - If File.Exists(sBTLPartFilePath) Then File.Delete(sBTLPartFilePath) - Bar.nCmdType = CalcIntegration.CmdType.CHECKGEN - End Select - TempBarList.Add(Bar) - Next - BarList = TempBarList.ToArray() - ElseIf Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) Then - Dim TempBarList(0) As CalcIntegration.Bar - If Not Map.refProjectVM.BTLStructureVM.SelBTLPart.bDO Then Return - Dim Bar As New CalcIntegration.Bar With {.nBarId = Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId, - .nBarType = ProjectType.PROJ, - .bBarOk = True} - Select Case Map.refProjectVM.BTLStructureVM.SelBTLPart.nGlobalState - Case Core.CalcStates.OK, CalcStates.INFO - Bar.nCmdType = CalcIntegration.CmdType.GENERATE - Case Else - Dim sBTLPartFilePath As String = Map.refProjManagerVM.CurrProj.sProjDirPath & "\" & Map.refProjectVM.BTLStructureVM.SelBTLPart.nPDN.ToString() & ".ori.bwe" - If File.Exists(sBTLPartFilePath) Then File.Delete(sBTLPartFilePath) - Bar.nCmdType = CalcIntegration.CmdType.CHECKGEN - End Select - TempBarList(0) = Bar - BarList = TempBarList - Else - Return - End If - ' disabilito interfaccia - Map.refProjectVM.ManageIsEnabled(False) - ' lancio calcolo - Calc.Run(BarList, Map.refProjManagerVM.CurrProj.sProjDirPath, AddressOf ManageCalc) - - ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING Then - If ((Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift) Then - Dim TempBarList(Map.refMachGroupPanelVM.MachGroupVMList.Count - 1) As CalcIntegration.Bar - For PartIndex = 0 To Map.refMachGroupPanelVM.MachGroupVMList.Count - 1 - Dim CurrMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.MachGroupVMList(PartIndex) - Dim Bar As New CalcIntegration.Bar With {.nBarId = CurrMachGroup.Id, - .nBarType = ProjectType.PROD, - .bBarOk = True} - Select Case CurrMachGroup.nGlobalState - Case Core.CalcStates.OK, CalcStates.INFO - Bar.nCmdType = CalcIntegration.CmdType.GENERATE - Case Else - Dim sMachGroupFilePath As String = Map.refProdManagerVM.CurrProd.sProdDirPath & "\" & CurrMachGroup.Name.ToString() & ".ori.bwe" - If File.Exists(sMachGroupFilePath) Then File.Delete(sMachGroupFilePath) - Bar.nCmdType = CalcIntegration.CmdType.CHECKGEN - End Select - TempBarList(PartIndex) = Bar - Next - BarList = TempBarList - ElseIf Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then - Dim TempBarList(0) As CalcIntegration.Bar - Dim Bar As New CalcIntegration.Bar With {.nBarId = Map.refMachGroupPanelVM.SelectedMachGroup.Id, - .nBarType = ProjectType.PROD, - .bBarOk = True} - Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup - Select Case SelMachGroup.nGlobalState - Case Core.CalcStates.OK, CalcStates.INFO - Bar.nCmdType = CalcIntegration.CmdType.GENERATE - Case Else - Dim sMachGroupFilePath As String = Map.refProdManagerVM.CurrProd.sProdDirPath & "\" & SelMachGroup.Name.ToString() & ".ori.bwe" - If File.Exists(sMachGroupFilePath) Then File.Delete(sMachGroupFilePath) - Bar.nCmdType = CalcIntegration.CmdType.CHECKGEN - End Select - TempBarList(0) = Bar - BarList = TempBarList - Else - Return - End If - ' disabilito interfaccia - Map.refProjectVM.ManageIsEnabled(False) - ' lancio calcolo - Calc.Run(BarList, Map.refProdManagerVM.CurrProd.sProdDirPath, AddressOf ManageCalc) - End If - End Sub - - ' funzione che gestisce risposta da thread di verifica, aggiorna progress e segnala comando di interruzione - Private Sub ManageCalc(dProgress As Double, sProgress As String, ByRef bCancel As Boolean) - If dProgress = 0 Then - Map.refMyStatusBarVM.SetLoadingProgress_Visibility(True) - Map.refMyStatusBarVM.SetStopProgress_IsActive(True) - Map.refMyStatusBarVM.SetStopProgress_IsEnabled(True) - Map.refMyStatusBarVM.SetOutputMessage(sProgress) - Map.refMyStatusBarVM.SetStopProgress_IsActive(True) - Map.refMyStatusBarVM.SetStopProgress_IsEnabled(True) - ElseIf dProgress = 1 Then - Map.refMyStatusBarVM.SetLoadingProgress_Visibility(False) - Map.refMyStatusBarVM.SetStopProgress_IsActive(False) - Map.refMyStatusBarVM.SetStopProgress_IsEnabled(False) - Map.refMyStatusBarVM.SetOutputMessage(sProgress, 3) - End If - bCancel = Map.refMyStatusBarVM.bStopProgress - Map.refMyStatusBarVM.SetLoadingProgress(dProgress * 100) - Map.refMyStatusBarVM.SetOutputMessage(sProgress) - End Sub - -#End Region ' Verify - -#Region "Simulate" - - ''' - ''' Returns a command that do Open. - ''' - Public ReadOnly Property Simulate_Command As ICommand - Get - If m_cmdSimulate Is Nothing Then - m_cmdSimulate = New Command(AddressOf Simulate) - End If - Return m_cmdSimulate - End Get - End Property - - ''' - ''' Execute the Open. This method is invoked by the OpenCommand. - ''' - Friend Sub Simulate() - Dim Calc As New CalcIntegration - Dim BarList() As CalcIntegration.Bar - If Map.refMainMenuVM.SelPage = Pages.VIEW Then - If Not IsNothing(Map.refProjectVM.BTLStructureVM.SelBTLPart) Then - Dim TempBarList(0) As CalcIntegration.Bar - Dim Bar As New CalcIntegration.Bar With {.nBarId = Map.refProjectVM.BTLStructureVM.SelBTLPart.nPartId, - .nBarType = ProjectType.PROJ, - .bBarOk = True, - .nCmdType = CalcIntegration.CmdType.SIMULATE} - If Map.refProjectVM.BTLStructureVM.SelBTLPart.nGlobalState <> Core.CalcStates.OK Then - Dim sBTLPartFilePath As String = Map.refProjManagerVM.CurrProj.sProjDirPath & "\" & Map.refProjectVM.BTLStructureVM.SelBTLPart.nPDN.ToString() & ".ori.bwe" - If File.Exists( sBTLPartFilePath) Then File.Delete( sBTLPartFilePath) - End If - TempBarList(0) = Bar - BarList = TempBarList - Else - Return - End If - ' disabilito interfaccia - Map.refProjectVM.ManageIsEnabled(False) - ' lancio simulazione - Calc.Run(BarList, Map.refProjManagerVM.CurrProj.sProjDirPath, AddressOf ManageCalc) - ElseIf Map.refMainMenuVM.SelPage = Pages.MACHINING Then - If Not IsNothing(Map.refMachGroupPanelVM.SelectedMachGroup) Then - Dim TempBarList(0) As CalcIntegration.Bar - Dim Bar As New CalcIntegration.Bar With {.nBarId = Map.refMachGroupPanelVM.SelectedMachGroup.Id, - .nBarType = ProjectType.PROD, - .bBarOk = True, - .nCmdType = CalcIntegration.CmdType.SIMULATE} - Dim SelMachGroup As MyMachGroupVM = Map.refMachGroupPanelVM.SelectedMachGroup - If SelMachGroup.nGlobalState <> Core.CalcStates.OK Then - Dim sMachGroupFilePath As String = Map.refProdManagerVM.CurrProd.sProdDirPath & "\" & SelMachGroup.Name.ToString() & ".ori.bwe" - If File.Exists( sMachGroupFilePath) Then File.Delete( sMachGroupFilePath) - End If - TempBarList(0) = Bar - BarList = TempBarList - Else - Return - End If - ' disabilito interfaccia - Map.refProjectVM.ManageIsEnabled(False) - ' lancio simulazione - Calc.Run(BarList, Map.refProdManagerVM.CurrProd.sProdDirPath, AddressOf ManageCalc) - End If - End Sub - -#End Region ' Simulate - #End Region ' COMMANDS End Class diff --git a/EgtBEAMWALL.ViewerOptimizer/MachGroupPanel/BeamMachGroupVM.vb b/EgtBEAMWALL.ViewerOptimizer/MachGroupPanel/BeamMachGroupVM.vb index 6127dc94..46a379a5 100644 --- a/EgtBEAMWALL.ViewerOptimizer/MachGroupPanel/BeamMachGroupVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/MachGroupPanel/BeamMachGroupVM.vb @@ -68,6 +68,7 @@ Public Class BeamMachGroupVM End Sub Private Sub ReadProductionState() + If IsNothing(Map.refProdManagerVM.CurrProd) OrElse IsNothing(Map.refProdManagerVM.CurrProd.nProdId) Then Return Dim MachGroupModel As MachGroupModel = DbControllers.m_MachGroupController.FindByMachGroupId(Map.refProdManagerVM.CurrProd.nProdId, Id) If Not IsNothing(MachGroupModel) Then If Not String.IsNullOrEmpty(MachGroupModel.SupervisorId) Then diff --git a/EgtBEAMWALL.ViewerOptimizer/Project/ProjectV.xaml b/EgtBEAMWALL.ViewerOptimizer/Project/ProjectV.xaml index 71ab36a2..2cb11748 100644 --- a/EgtBEAMWALL.ViewerOptimizer/Project/ProjectV.xaml +++ b/EgtBEAMWALL.ViewerOptimizer/Project/ProjectV.xaml @@ -33,6 +33,7 @@ Visibility="{Binding DataContext.ShowBeamPanel_Visibility, RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:ProjectV}}}"/> + diff --git a/EgtBEAMWALL.ViewerOptimizer/Project/ProjectVM.vb b/EgtBEAMWALL.ViewerOptimizer/Project/ProjectVM.vb index de82c66b..497b51ab 100644 --- a/EgtBEAMWALL.ViewerOptimizer/Project/ProjectVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/Project/ProjectVM.vb @@ -169,6 +169,7 @@ Friend Sub ManageIsEnabled(bIsEnabled As Boolean) Map.refInstrumentPanelVM.SetInstrumentPanelIsEnabled(bIsEnabled) + Map.refCALCPanelVM.SetCalcPanelIsEnabled(bIsEnabled) Map.refMainMenuVM.SetMainMenuIsEnabled(bIsEnabled) Map.refPartManagerVM.SetPartManagerIsEnabled(bIsEnabled) Map.refLeftPanelVM.SetLeftPanelIsEnabled(bIsEnabled) diff --git a/EgtBEAMWALL.ViewerOptimizer/Utility/Dictionary.xaml b/EgtBEAMWALL.ViewerOptimizer/Utility/Dictionary.xaml index 7ef7fd3b..30ec9ce5 100644 --- a/EgtBEAMWALL.ViewerOptimizer/Utility/Dictionary.xaml +++ b/EgtBEAMWALL.ViewerOptimizer/Utility/Dictionary.xaml @@ -20,6 +20,7 @@ + diff --git a/EgtBEAMWALL.ViewerOptimizer/Utility/Map.vb b/EgtBEAMWALL.ViewerOptimizer/Utility/Map.vb index 24e4fabf..1a4554b2 100644 --- a/EgtBEAMWALL.ViewerOptimizer/Utility/Map.vb +++ b/EgtBEAMWALL.ViewerOptimizer/Utility/Map.vb @@ -25,6 +25,7 @@ Module Map Private m_refInstrumentPanelVM As InstrumentPanelVM Private m_refTopPanelVM As TopPanelVM Private m_refOptimizePanelVM As OptimizePanelVM + Private m_refCALCPanelVM As CALCPanelVM 'Private m_refOpenProjectFileDialogVM As OpenProjectFileDialogVM 'Private m_refRawPartTabVM As RawPartTabVM 'Private m_refNestingTabVM As NestingTabVM @@ -178,6 +179,12 @@ Module Map End Get End Property + Public ReadOnly Property refCALCPanelVM As CALCPanelVM + Get + Return m_refCALCPanelVM + End Get + End Property + 'Public ReadOnly Property refOpenProjectFileDialogVM As OpenProjectFileDialogVM ' Get ' Return m_refOpenProjectFileDialogVM @@ -345,6 +352,11 @@ Module Map Return Not IsNothing(m_refOptimizePanelVM) End Function + Friend Function SetRefCALCPanelVM(CALCPanelVM As CALCPanelVM) As Boolean + m_refCALCPanelVM = CALCPanelVM + Return Not IsNothing(m_refCALCPanelVM) + End Function + 'Friend Function SetRefOpenProjectFileDialogVM(OpenProjectFileDialogVM As OpenProjectFileDialogVM) As Boolean ' m_refOpenProjectFileDialogVM = OpenProjectFileDialogVM ' Return Not IsNothing(m_refOpenProjectFileDialogVM) @@ -413,7 +425,8 @@ Module Map Not IsNothing(m_refFreeContourManagerVM) AndAlso Not IsNothing(m_refFreeContourInputVM) AndAlso Not IsNothing(m_refInstrumentPanelVM) AndAlso Not IsNothing(m_refTopPanelVM) AndAlso Not IsNothing(m_refPartManagerVM) AndAlso Not IsNothing(m_refOptimizePanelVM) AndAlso - Not IsNothing(m_refShowBeamPanelVM) AndAlso LibMap.EndInit() + Not IsNothing(m_refShowBeamPanelVM) AndAlso Not IsNothing(m_refCALCPanelVM) AndAlso + LibMap.EndInit() End Function #End Region ' Init diff --git a/EgtBEAMWALL.sln b/EgtBEAMWALL.sln index 61faa098..1465514f 100644 --- a/EgtBEAMWALL.sln +++ b/EgtBEAMWALL.sln @@ -13,40 +13,58 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EgtBEAMWALL.Core", "EgtBEAM EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU Debug|x64 = Debug|x64 Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU Release|x64 = Release|x64 Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {57291955-F9C4-4466-8D53-476D43BA3659}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {57291955-F9C4-4466-8D53-476D43BA3659}.Debug|Any CPU.Build.0 = Debug|Any CPU {57291955-F9C4-4466-8D53-476D43BA3659}.Debug|x64.ActiveCfg = Debug|x64 {57291955-F9C4-4466-8D53-476D43BA3659}.Debug|x64.Build.0 = Debug|x64 {57291955-F9C4-4466-8D53-476D43BA3659}.Debug|x86.ActiveCfg = Debug|x86 {57291955-F9C4-4466-8D53-476D43BA3659}.Debug|x86.Build.0 = Debug|x86 + {57291955-F9C4-4466-8D53-476D43BA3659}.Release|Any CPU.ActiveCfg = Release|Any CPU + {57291955-F9C4-4466-8D53-476D43BA3659}.Release|Any CPU.Build.0 = Release|Any CPU {57291955-F9C4-4466-8D53-476D43BA3659}.Release|x64.ActiveCfg = Release|x64 {57291955-F9C4-4466-8D53-476D43BA3659}.Release|x64.Build.0 = Release|x64 {57291955-F9C4-4466-8D53-476D43BA3659}.Release|x86.ActiveCfg = Release|x86 {57291955-F9C4-4466-8D53-476D43BA3659}.Release|x86.Build.0 = Release|x86 + {B71DA327-38C8-4305-BBA1-34F3F3F32405}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B71DA327-38C8-4305-BBA1-34F3F3F32405}.Debug|Any CPU.Build.0 = Debug|Any CPU {B71DA327-38C8-4305-BBA1-34F3F3F32405}.Debug|x64.ActiveCfg = Debug|x64 {B71DA327-38C8-4305-BBA1-34F3F3F32405}.Debug|x64.Build.0 = Debug|x64 {B71DA327-38C8-4305-BBA1-34F3F3F32405}.Debug|x86.ActiveCfg = Debug|x86 {B71DA327-38C8-4305-BBA1-34F3F3F32405}.Debug|x86.Build.0 = Debug|x86 + {B71DA327-38C8-4305-BBA1-34F3F3F32405}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B71DA327-38C8-4305-BBA1-34F3F3F32405}.Release|Any CPU.Build.0 = Release|Any CPU {B71DA327-38C8-4305-BBA1-34F3F3F32405}.Release|x64.ActiveCfg = Release|x64 {B71DA327-38C8-4305-BBA1-34F3F3F32405}.Release|x64.Build.0 = Release|x64 {B71DA327-38C8-4305-BBA1-34F3F3F32405}.Release|x86.ActiveCfg = Release|x86 {B71DA327-38C8-4305-BBA1-34F3F3F32405}.Release|x86.Build.0 = Release|x86 + {24D7760E-662A-47E4-B729-B70126C24A31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {24D7760E-662A-47E4-B729-B70126C24A31}.Debug|Any CPU.Build.0 = Debug|Any CPU {24D7760E-662A-47E4-B729-B70126C24A31}.Debug|x64.ActiveCfg = Debug|Any CPU {24D7760E-662A-47E4-B729-B70126C24A31}.Debug|x64.Build.0 = Debug|Any CPU {24D7760E-662A-47E4-B729-B70126C24A31}.Debug|x86.ActiveCfg = Debug|Any CPU {24D7760E-662A-47E4-B729-B70126C24A31}.Debug|x86.Build.0 = Debug|Any CPU + {24D7760E-662A-47E4-B729-B70126C24A31}.Release|Any CPU.ActiveCfg = Release|Any CPU + {24D7760E-662A-47E4-B729-B70126C24A31}.Release|Any CPU.Build.0 = Release|Any CPU {24D7760E-662A-47E4-B729-B70126C24A31}.Release|x64.ActiveCfg = Release|Any CPU {24D7760E-662A-47E4-B729-B70126C24A31}.Release|x64.Build.0 = Release|Any CPU {24D7760E-662A-47E4-B729-B70126C24A31}.Release|x86.ActiveCfg = Release|Any CPU {24D7760E-662A-47E4-B729-B70126C24A31}.Release|x86.Build.0 = Release|Any CPU + {F22835A1-83D8-4334-91BB-BAAEB9CF59B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F22835A1-83D8-4334-91BB-BAAEB9CF59B1}.Debug|Any CPU.Build.0 = Debug|Any CPU {F22835A1-83D8-4334-91BB-BAAEB9CF59B1}.Debug|x64.ActiveCfg = Debug|Any CPU {F22835A1-83D8-4334-91BB-BAAEB9CF59B1}.Debug|x64.Build.0 = Debug|Any CPU {F22835A1-83D8-4334-91BB-BAAEB9CF59B1}.Debug|x86.ActiveCfg = Debug|Any CPU {F22835A1-83D8-4334-91BB-BAAEB9CF59B1}.Debug|x86.Build.0 = Debug|Any CPU + {F22835A1-83D8-4334-91BB-BAAEB9CF59B1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F22835A1-83D8-4334-91BB-BAAEB9CF59B1}.Release|Any CPU.Build.0 = Release|Any CPU {F22835A1-83D8-4334-91BB-BAAEB9CF59B1}.Release|x64.ActiveCfg = Release|Any CPU {F22835A1-83D8-4334-91BB-BAAEB9CF59B1}.Release|x64.Build.0 = Release|Any CPU {F22835A1-83D8-4334-91BB-BAAEB9CF59B1}.Release|x86.ActiveCfg = Release|Any CPU diff --git a/TPAComm/MachCommConst.vb b/TPAComm/MachCommConst.vb new file mode 100644 index 00000000..41c36f12 --- /dev/null +++ b/TPAComm/MachCommConst.vb @@ -0,0 +1,35 @@ +Imports EgtBEAMWALL.Core.ConstMachComm + +Module MachCommConst + + Public Enum PVars As Integer + PROD = 0 + MACHGROUP = 1 + PART = 2 + STATE = 3 + End Enum + + ' stati pezzo + Public Enum PartState As Integer + NULL = 0 + START = 1 + END_ = 2 + End Enum + + Public Delegate Sub ResultCallbackDlg(CommandType As CommandTypes, CommandState As CommandStates, ResultType As ResultTypes, Params As String) + Public Delegate Sub CloseCallbackDlg(ByRef bCancel As Boolean) + Public Delegate Sub UpdateCallbackDlg(Param As String, Params As String) + Public Delegate Sub AlarmCallbackDlg(ByVal AlarmOperation As Integer, ByVal AlarmType As Integer, ByVal AlarmMessage As String, ByVal AlarmCode As String, ByVal AlarmDateTime As String) + Public Delegate Sub AxisCoordinatesCallbackDlg(ByVal AxisValue As Double, ByVal AxisIndex As Integer) + Public Delegate Sub OpStateCallbackDlg(ByVal newOpState As ISOCNC.Remoting.MachineOperatingState) + Public Delegate Sub ReadVarCallbackDlg(CommandExecutedCorrectly As Boolean, VarAddress As String, VarValue As String, VarType As Integer) + + Friend m_ResultCallbackDlg As ResultCallbackDlg + Friend m_CloseCallbackDlg As CloseCallbackDlg + Friend m_UpdateCallbackDlg As UpdateCallbackDlg + Friend m_AlarmCallbackDlg As AlarmCallbackDlg + Friend m_AxisCoordinatesCallbackDlg As AxisCoordinatesCallbackDlg + Friend m_OpStateCallbackDlg As OpStateCallbackDlg + Friend m_ReadVarCallbackDlg As ReadVarCallbackDlg + +End Module diff --git a/TPAComm/My Project/Application.Designer.vb b/TPAComm/My Project/Application.Designer.vb new file mode 100644 index 00000000..88dd01c7 --- /dev/null +++ b/TPAComm/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/TPAComm/My Project/Application.myapp b/TPAComm/My Project/Application.myapp new file mode 100644 index 00000000..758895de --- /dev/null +++ b/TPAComm/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 1 + true + diff --git a/TPAComm/My Project/AssemblyInfo.vb b/TPAComm/My Project/AssemblyInfo.vb new file mode 100644 index 00000000..4e623966 --- /dev/null +++ b/TPAComm/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: +' + + + diff --git a/TPAComm/My Project/Resources.Designer.vb b/TPAComm/My Project/Resources.Designer.vb new file mode 100644 index 00000000..9fcb6b66 --- /dev/null +++ b/TPAComm/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("TPAComm.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As Global.System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/TPAComm/My Project/Resources.resx b/TPAComm/My Project/Resources.resx new file mode 100644 index 00000000..af7dbebb --- /dev/null +++ b/TPAComm/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/TPAComm/My Project/Settings.Designer.vb b/TPAComm/My Project/Settings.Designer.vb new file mode 100644 index 00000000..a363f8f9 --- /dev/null +++ b/TPAComm/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.TPAComm.My.MySettings + Get + Return Global.TPAComm.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/TPAComm/My Project/Settings.settings b/TPAComm/My Project/Settings.settings new file mode 100644 index 00000000..85b890b3 --- /dev/null +++ b/TPAComm/My Project/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/TPAComm/RWVariableManager.vb b/TPAComm/RWVariableManager.vb new file mode 100644 index 00000000..d3c072c1 --- /dev/null +++ b/TPAComm/RWVariableManager.vb @@ -0,0 +1,218 @@ +Imports EgtBEAMWALL.Core.ConstMachComm +Imports EgtUILib +Imports EgtWPFLib5 +Imports ISOCNC.Remoting + +Public Class RWVariableManager + + Private m_Tpa As TPAComm = Nothing + Friend ReadOnly Property Tpa As TPAComm + Get + Return m_Tpa + End Get + End Property + + Private m_Proxy_VariableCommandExecutedEventHandler As New VariableCommandExecutedEventHandler(AddressOf RemoteObject_VariableCommandExecuted) + + ' lock per Synclock + Private m_CopyLock As New Object + Private m_ReadLock As New Object + ' lista variabili in lettura + Private Shared m_ReadingVars(19) As CommVar + Public Shared ReadOnly Property ReadingVars As CommVar() + Get + Return m_ReadingVars + End Get + End Property + + ' lista variabili lette + Public Shared m_ReadedVars(19) As String + + Protected Sub New() + End Sub + + Friend Sub OnDispose() + RemoveHandler m_Tpa.eventProxy.VariableCommandExecuted, m_Proxy_VariableCommandExecutedEventHandler + 'RemoveHandler m_Tpa.MachManaging.Timer.Tick, AddressOf Timer_Tick + End Sub + + 'Friend Sub Timer_Tick(sender As Object, e As EventArgs) + ' ' leggo tutte le variabili + ' RefreshAllVars() + 'End Sub + + Friend Shared Function CreateRWVariableManager(Tpa As TPAComm) + Dim NewRWVariableManager As New RWVariableManager + NewRWVariableManager.m_Tpa = Tpa + AddHandler NewRWVariableManager.m_Tpa.eventProxy.VariableCommandExecuted, NewRWVariableManager.m_Proxy_VariableCommandExecutedEventHandler + Return NewRWVariableManager + End Function + + Public Sub RefreshAllVars() + EgtOutLog("RefreshAllVars") + For Each Var In m_ReadingVars + ' rileggo solo variabili continue + If Not IsNothing(Var) AndAlso Var.sType = CommVar.CommVarTypes.CONTINUOUS Then IntRefreshVar(Var.sAddress) + Next + End Sub + + Public Shared Function InitVar(Name As String, Address As String, Type As CommVar.CommVarTypes) As Integer + Dim Index As Integer = Array.IndexOf(m_ReadingVars, Nothing) + m_ReadingVars(Index) = New CommVar(Name, Address, Type) + Return Index + End Function + + Public Sub RefreshVar(Name As String) + Dim Var As CommVar = GetReadVarFromName(Name) + Var.ResetReading() + IntRefreshVar(Var.sAddress) + End Sub + + Public Sub WriteVar(Name As String, Value As String) + IntWriteVar(GetReadVarFromName(Name).sAddress, Value) + End Sub + + Private Sub IntRefreshVar(Address As String) + Tpa.remObject.SetVariableCommand(ISOCNC.Remoting.VariableCommands.ReadVar, Address, "") + End Sub + + Private Sub IntWriteVar(Address As String, Value As String) + Tpa.remObject.SetVariableCommand(ISOCNC.Remoting.VariableCommands.WriteVar, Address, Value) + End Sub + + Public Sub ReadVar(Name As String, ByRef Value As String) + Value = m_ReadedVars(GetIndexFromName(Name)) + End Sub + Public Sub ReadVar(Name As String, ByRef Value As Integer) + Integer.TryParse(m_ReadedVars(GetIndexFromName(Name)), Value) + End Sub + Public Sub ReadVar(Name As String, ByRef Value As Double) + Value = StringToDouble(m_ReadedVars(GetIndexFromName(Name)), 5) + End Sub + + Private Shared Function GetIndexFromName(Name As String) As Integer + Return Array.FindIndex(m_ReadingVars, Function(x) If(Not IsNothing(x), x.sName = Name, False)) + End Function + Friend Shared Function GetReadVarFromName(Name As String) As CommVar + Return m_ReadingVars(GetIndexFromName(Name)) + End Function + Private Shared Function GetIndexFromAddress(Address As String) As Integer + Return Array.FindIndex(m_ReadingVars, Function(x) If(Not IsNothing(x), x.sAddress = Address, False)) + End Function + Friend Shared Function GetReadVarFromAddress(Address As String) As CommVar + Return m_ReadingVars(GetIndexFromAddress(Address)) + End Function + Friend Shared Function GetReadVarNameFromAddress(Address As String) As String + Dim Var As CommVar = m_ReadingVars.FirstOrDefault(Function(x) If(Not IsNothing(x), x.sAddress = Address, False)) + Return If(Not IsNothing(Var), Var.sName, "") + End Function + + Private Sub UpdateContinuousVars() + Dim bReaded As Boolean = True + For Each Var In m_ReadingVars + If Not IsNothing(Var) AndAlso Var.sType = CommVar.CommVarTypes.CONTINUOUS AndAlso Not Var.bReaded Then + bReaded = False + Exit For + End If + Next + ' se lette tutte + If bReaded Then + ' aggiorno variabili + SyncLock m_CopyLock + For VarIndex = 0 To m_ReadingVars.Count - 1 + If Not IsNothing(m_ReadingVars(VarIndex)) Then + m_ReadedVars(VarIndex) = m_ReadingVars(VarIndex).sValue + End If + Next + End SyncLock + End If + End Sub + + Friend Sub UpdateVar(CommandExecutedCorrectly As Boolean, VarName As String, VarValue As String, VarType As Integer) + If CommandExecutedCorrectly Then + Dim Var As CommVar = GetReadVarFromAddress(VarName) + If Not IsNothing(Var) Then + 'Dim bChangedVal As Boolean = () + Var.SetValue(VarValue) + ' se variabile ripetitiva lancio update variabili ripetitive + If Var.sType = CommVar.CommVarTypes.CONTINUOUS Then + EgtOutLog(CommandExecutedCorrectly & " . " & VarName & " . " & VarValue) + EgtOutLog(Var.sName & " . " & Var.sAddress & " . " & Var.sValue & " . " & Var.bReaded) + UpdateContinuousVars() + Else + m_ReadVarCallbackDlg(CommandExecutedCorrectly, VarName, VarValue, VarType) + End If + End If + End If + End Sub + + Private Sub RemoteObject_VariableCommandExecuted(ByVal executedCommand As Integer, ByVal commandExecutedCorrectly As Boolean, ByVal varName As String, ByVal varValue As String, ByVal varType As Integer) + ' riporto valore variabile su array + Select Case executedCommand + Case VariableCommands.Error + Case VariableCommands.NotExecuted + Case VariableCommands.ReadVar + UpdateVar(commandExecutedCorrectly, varName, varValue, varType) + Case VariableCommands.WriteVar + m_ResultCallbackDlg(CommandTypes.WRITE, CommandStates.OK, ResultTypes.RESULT, "") + Case VariableCommands.ReadAxis + Case VariableCommands.ReadAny + End Select + End Sub + +End Class + +Public Class CommVar + + Public Enum CommVarTypes As Integer + ONETIME + CONTINUOUS + End Enum + + Private m_sName As String + Public ReadOnly Property sName As String + Get + Return m_sName + End Get + End Property + Private m_sAddress As String + Public ReadOnly Property sAddress As String + Get + Return m_sAddress + End Get + End Property + Private m_nType As CommVarTypes + Public ReadOnly Property sType As CommVarTypes + Get + Return m_nType + End Get + End Property + Private m_sValue As String + Public ReadOnly Property sValue As String + Get + Return m_sValue + End Get + End Property + Public Sub SetValue(Value As String) + m_sValue = Value + m_bReaded = True + End Sub + + Private m_bReaded As Boolean + Public ReadOnly Property bReaded As Boolean + Get + Return m_bReaded + End Get + End Property + + Sub New(Name As String, Address As String, Type As CommVarTypes) + m_sName = Name + m_sAddress = Address + m_nType = Type + End Sub + + Friend Sub ResetReading() + m_bReaded = False + End Sub + +End Class diff --git a/TPAComm/TPAComm.vb b/TPAComm/TPAComm.vb new file mode 100644 index 00000000..1fca6769 --- /dev/null +++ b/TPAComm/TPAComm.vb @@ -0,0 +1,244 @@ +Imports System +Imports System.Collections.Generic +Imports System.Linq +Imports System.Runtime.Remoting.Channels +Imports System.Runtime.Remoting.Channels.Ipc +Imports System.Security.Permissions +Imports System.Text +Imports System.Threading.Tasks +Imports System.Windows +Imports ISOCNC.Remoting + +Class TPAComm + + ' creo classe di gestione variabili + Private m_RWVariableManager As RWVariableManager + Friend ReadOnly Property RWVariableManager As RWVariableManager + Get + Return m_RWVariableManager + End Get + End Property + + Private m_MachManaging As MachManaging + Friend ReadOnly Property MachManaging As MachManaging + Get + Return m_MachManaging + End Get + End Property + + Private _axesVal As Double() = New Double(23) {} + Private _cmdActive As Integer = 0 + Private m_opState As ISOCNC.Remoting.MachineOperatingState = ISOCNC.Remoting.MachineOperatingState.Unspecified + Public ReadOnly Property opState As ISOCNC.Remoting.MachineOperatingState + Get + Return m_opState + End Get + End Property + Private _remObject As ISOCNC.Remoting_Server + + Public ReadOnly Property remObject As ISOCNC.Remoting_Server + Get + Return _remObject + End Get + End Property + + Private serverURI As String = "ipc://localhost:9090/IRemoteObject.rem" + Private m_eventProxy As ISOCNC.Remoting.EventProxyManager + Friend ReadOnly Property eventProxy As ISOCNC.Remoting.EventProxyManager + Get + Return m_eventProxy + End Get + End Property + + Private _rpc As Integer + Private _prgCount As Integer + Private _prgAtIndex As String + Private _prgList As String() + Private _prgListUpdated As Boolean + Private _errCycle As String + Private _iso As String + Private _message As String + Private _errSystem As String + + Private m_Proxy_CommandExecutedEventHandler As New CommandExecutedEventHandler(AddressOf RemoteObject_CommandExecuted) + Private m_Proxy_ServerErrorEventHandler As New ServerErrorEventHandler(AddressOf RemoteObject_ServerError) + Private m_Proxy_AxesCoordinatesUpdateEventHandler As New AxesCoordinatesUpdateEventHandler(AddressOf RemoteObject_AxisCoordinatesUpdate) + Private m_Proxy_OpStateUpdateEventHandler As New OpStateUpdateEventHandler(AddressOf RemoteObject_OpStateUpdate) + Private m_Proxy_AlarmNotificationEventHandler As New AlarmNotificationEventHandler(AddressOf RemoteObject_AlarmNotification) + Private m_Proxy_ListInfoEventHandler As New ListInfoEventHandler(AddressOf RemoteObject_ListInfoResponse) + Private m_Proxy_RPCUpdateEventHandler As New RPCUpdateEventHandler(AddressOf RemoteObject_RPCUpdate) + Private m_Proxy_VariableCommandExecutedEventHandler As New VariableCommandExecutedEventHandler(AddressOf RemoteObject_VariableCommandExecuted) + Private m_Proxy_TickUpdateEventHandler As New TickUpdateEventHandler(AddressOf RemoteObject_TickUpdate) + Private m_Rem_CommandExecutedEventHandler As CommandExecutedEventHandler + Private m_Rem_ServerErrorEventHandler As ServerErrorEventHandler + Private m_Rem_AxesCoordinatesUpdateEventHandler As AxesCoordinatesUpdateEventHandler + Private m_Rem_OpStateUpdateEventHandler As OpStateUpdateEventHandler + Private m_Rem_AlarmNotificationEventHandler As AlarmNotificationEventHandler + Private m_Rem_ListInfoEventHandler As ListInfoEventHandler + Private m_Rem_RPCUpdateEventHandler As RPCUpdateEventHandler + Private m_Rem_VariableCommandExecutedEventHandler As VariableCommandExecutedEventHandler + + + + Public Sub New(Machmanaging As MachManaging) + m_MachManaging = Machmanaging + Dim properties As System.Collections.Hashtable = New System.Collections.Hashtable() + properties("name") = "remotingClient" + properties("priority") = "20" + properties("portName") = "67" + Dim clientProv As BinaryClientFormatterSinkProvider = New BinaryClientFormatterSinkProvider() + Dim serverProv As BinaryServerFormatterSinkProvider = New BinaryServerFormatterSinkProvider() + serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full + Dim channel As IpcChannel = New IpcChannel(properties, clientProv, serverProv) + System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(channel, False) + Dim remoteType As System.Runtime.Remoting.WellKnownClientTypeEntry = New System.Runtime.Remoting.WellKnownClientTypeEntry(GetType(ISOCNC.Remoting_Server), serverURI) + System.Runtime.Remoting.RemotingConfiguration.RegisterWellKnownClientType(remoteType) + Dim objectUri As String + Dim messageSink As System.Runtime.Remoting.Messaging.IMessageSink = channel.CreateMessageSink("ipc://localhost:9090/IRemoteObject.rem", Nothing, objectUri) + Console.WriteLine("The URI of the message sink is {0}.", objectUri) + + If messageSink IsNot Nothing Then + Console.WriteLine("The type of the message sink is {0}.", messageSink.[GetType]().ToString()) + End If + + m_eventProxy = New ISOCNC.Remoting.EventProxyManager() + AddHandler m_eventProxy.CommandExecuted, m_Proxy_CommandExecutedEventHandler + AddHandler m_eventProxy.ServerError, m_Proxy_ServerErrorEventHandler + AddHandler m_eventProxy.AxisCoordinatesUpdate, m_Proxy_AxesCoordinatesUpdateEventHandler + AddHandler m_eventProxy.OpStateUpdate, m_Proxy_OpStateUpdateEventHandler + AddHandler m_eventProxy.AlarmNotification, m_Proxy_AlarmNotificationEventHandler + AddHandler m_eventProxy.ListInfoResponse, m_Proxy_ListInfoEventHandler + AddHandler m_eventProxy.RPCUpdate, m_Proxy_RPCUpdateEventHandler + AddHandler m_eventProxy.VariableCommandExecuted, m_Proxy_VariableCommandExecutedEventHandler + AddHandler m_eventProxy.TickUpdate, m_Proxy_TickUpdateEventHandler + + _remObject = CType(Activator.GetObject(GetType(ISOCNC.Remoting_Server), serverURI), ISOCNC.Remoting_Server) + Try + m_Rem_CommandExecutedEventHandler = New CommandExecutedEventHandler(AddressOf m_eventProxy.LocallyHandleCommandExecuted) + m_Rem_ServerErrorEventHandler = New ServerErrorEventHandler(AddressOf m_eventProxy.LocallyHandleServerError) + m_Rem_AxesCoordinatesUpdateEventHandler = New AxesCoordinatesUpdateEventHandler(AddressOf m_eventProxy.LocallyHandleAxisCoordinatesUpdate) + m_Rem_OpStateUpdateEventHandler = New OpStateUpdateEventHandler(AddressOf m_eventProxy.LocallyHandleOpStateUpdate) + m_Rem_AlarmNotificationEventHandler = New AlarmNotificationEventHandler(AddressOf m_eventProxy.LocallyHandleAlarmNotification) + m_Rem_ListInfoEventHandler = New ListInfoEventHandler(AddressOf m_eventProxy.LocallyHandleListInfo) + m_Rem_RPCUpdateEventHandler = New RPCUpdateEventHandler(AddressOf m_eventProxy.LocallyHandleRPCUpdate) + m_Rem_VariableCommandExecutedEventHandler = New VariableCommandExecutedEventHandler(AddressOf m_eventProxy.LocallyHandleVariableCommandExecuted) + AddHandler _remObject.CommandExecuted, m_Rem_CommandExecutedEventHandler + AddHandler _remObject.ServerError, m_Rem_ServerErrorEventHandler + AddHandler _remObject.AxisCoordinatesUpdate, m_Rem_AxesCoordinatesUpdateEventHandler + AddHandler _remObject.OpStateUpdate, m_Rem_OpStateUpdateEventHandler + AddHandler _remObject.AlarmNotification, m_Rem_AlarmNotificationEventHandler + AddHandler _remObject.ListInfoResponse, m_Rem_ListInfoEventHandler + AddHandler _remObject.RPCUpdate, m_Rem_RPCUpdateEventHandler + AddHandler _remObject.VariableCommandExecuted, m_Rem_VariableCommandExecutedEventHandler + Catch ex As System.Runtime.Remoting.RemotingException + Dim dR As MessageBoxResult = MessageBox.Show(ex.Message) + End Try + ' creo classe che gestisce variabili + m_RWVariableManager = RWVariableManager.CreateRWVariableManager(Me) + End Sub + + Friend Sub OnDispose() + RemoveHandler _remObject.CommandExecuted, m_Rem_CommandExecutedEventHandler + RemoveHandler _remObject.ServerError, m_Rem_ServerErrorEventHandler + RemoveHandler _remObject.AxisCoordinatesUpdate, m_Rem_AxesCoordinatesUpdateEventHandler + RemoveHandler _remObject.OpStateUpdate, m_Rem_OpStateUpdateEventHandler + RemoveHandler _remObject.AlarmNotification, m_Rem_AlarmNotificationEventHandler + RemoveHandler _remObject.ListInfoResponse, m_Rem_ListInfoEventHandler + RemoveHandler _remObject.RPCUpdate, m_Rem_RPCUpdateEventHandler + RemoveHandler _remObject.VariableCommandExecuted, m_Rem_VariableCommandExecutedEventHandler + RemoveHandler m_eventProxy.CommandExecuted, m_Proxy_CommandExecutedEventHandler + RemoveHandler m_eventProxy.ServerError, m_Proxy_ServerErrorEventHandler + RemoveHandler m_eventProxy.AxisCoordinatesUpdate, m_Proxy_AxesCoordinatesUpdateEventHandler + RemoveHandler m_eventProxy.OpStateUpdate, m_Proxy_OpStateUpdateEventHandler + RemoveHandler m_eventProxy.AlarmNotification, m_Proxy_AlarmNotificationEventHandler + RemoveHandler m_eventProxy.ListInfoResponse, m_Proxy_ListInfoEventHandler + RemoveHandler m_eventProxy.RPCUpdate, m_Proxy_RPCUpdateEventHandler + RemoveHandler m_eventProxy.VariableCommandExecuted, m_Proxy_VariableCommandExecutedEventHandler + RemoveHandler m_eventProxy.TickUpdate, m_Proxy_TickUpdateEventHandler + End Sub + + Private Sub RemoteObject_OpStateUpdate(ByVal newOpState As ISOCNC.Remoting.MachineOperatingState) + ' resetto stato pending iniziale + If Map.refMachManaging.StartPending AndAlso newOpState = MachineOperatingState.Pending Then + MachManaging.ResetStartPending() + End If + m_opState = newOpState + m_OpStateCallbackDlg(newOpState) + End Sub + + Private Sub RemoteObject_CommandExecuted(ByVal executedCommand As Integer) + Select Case executedCommand + Case CInt(ISOCNC.Remoting.Commands.NoCommand) + Case CInt(ISOCNC.Remoting.Commands.[End]) + m_ResultCallbackDlg(CommandTypes.RESET, CommandStates.OK, ResultTypes.RESULT, "") + Case CInt(ISOCNC.Remoting.Commands.[Error]) + m_ResultCallbackDlg(CommandTypes.ERROR_, CommandStates.ERROR_, ResultTypes.RESULT, "") + Case CInt(ISOCNC.Remoting.Commands.MDI_End) + Case CInt(ISOCNC.Remoting.Commands.MDI_Start) + Case CInt(ISOCNC.Remoting.Commands.MDI_Stop) + Case CInt(ISOCNC.Remoting.Commands.SetPoint) + m_ResultCallbackDlg(CommandTypes.SETPOINT, CommandStates.OK, ResultTypes.RESULT, "") + Case CInt(ISOCNC.Remoting.Commands.Start) + m_ResultCallbackDlg(CommandTypes.START, CommandStates.OK, ResultTypes.RESULT, "") + Case CInt(ISOCNC.Remoting.Commands.[Step]) + m_ResultCallbackDlg(CommandTypes.STEP_, CommandStates.OK, ResultTypes.RESULT, "") + Case CInt(ISOCNC.Remoting.Commands.[Stop]) + m_ResultCallbackDlg(CommandTypes.STOP_, CommandStates.OK, ResultTypes.RESULT, "") + Case CInt(ISOCNC.Remoting.Commands.Start_Program_Soft) + m_ResultCallbackDlg(CommandTypes.SOFTSTART, CommandStates.OK, ResultTypes.RESULT, "") + Case Else + End Select + _cmdActive = CInt(executedCommand) + End Sub + + Private Sub RemoteObject_ServerError(ByVal sender As Object, ByVal seEA As ISOCNC.Remoting.ServerErrorEventArgs) + m_ResultCallbackDlg(CommandTypes.ERROR_, CommandStates.ERROR_, ResultTypes.RESULT, "Server Error: " & seEA.[Error]) + Dim dr As MessageBoxResult = MessageBox.Show("Server Error: " & seEA.[Error]) + End Sub + + Private Sub RemoteObject_AxisCoordinatesUpdate(ByVal axisValue As Double, ByVal axisIndex As Integer) + m_AxisCoordinatesCallbackDlg(axisValue, axisIndex) + End Sub + + Private Sub RemoteObject_RPCUpdate(ByVal newRPC As UInteger) + _rpc = CInt(newRPC) + End Sub + + Private Sub RemoteObject_ListInfoResponse(ByVal prgCount As Integer, ByVal prgAtIndex As String, ByVal prgList As String()) + If prgCount >= 0 Then + _prgCount = prgCount + End If + + If prgAtIndex <> "" Then + _prgAtIndex = prgAtIndex + End If + + If prgList IsNot Nothing AndAlso prgList.Length > 0 Then + _prgList = prgList + _prgListUpdated = True + End If + End Sub + + Private Sub RemoteObject_AlarmNotification(ByVal alarmOperation As Integer, ByVal alarmType As Integer, ByVal alarmMessage As String, ByVal alarmCode As String, ByVal alarmDateTime As String) + ' restituisco errore ad interfaccia + m_AlarmCallbackDlg(alarmOperation, alarmType, alarmMessage, alarmCode, alarmDateTime) + End Sub + + Private Sub RemoteObject_VariableCommandExecuted(ByVal executedCommand As Integer, ByVal commandExecutedCorrectly As Boolean, ByVal varName As String, ByVal varValue As String, ByVal varType As Integer) + ' riporto valore variabile su array + Select Case executedCommand + Case VariableCommands.Error + Case VariableCommands.NotExecuted + Case VariableCommands.ReadVar + m_RWVariableManager.UpdateVar(commandExecutedCorrectly, varName, varValue, varType) + Case VariableCommands.WriteVar + m_ResultCallbackDlg(CommandTypes.WRITE, If(commandExecutedCorrectly, CommandStates.OK, CommandStates.ERROR_), ResultTypes.RESULT, varName & "=" & varValue) + Case VariableCommands.ReadAxis + Case VariableCommands.ReadAny + End Select + End Sub + + Private Sub RemoteObject_TickUpdate(ByVal newTick As ULong) + End Sub + +End Class diff --git a/TPAComm/TPAComm.vbproj b/TPAComm/TPAComm.vbproj new file mode 100644 index 00000000..0bac4921 --- /dev/null +++ b/TPAComm/TPAComm.vbproj @@ -0,0 +1,107 @@ + + + + + Debug + AnyCPU + {88965904-0382-4F05-AFAF-1A008C2A5A25} + Library + TPAComm + TPAComm + 512 + Windows + v4.7.2 + true + + + true + full + true + true + bin\Debug\ + TPAComm.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + pdbonly + false + true + true + bin\Release\ + TPAComm.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + On + + + Binary + + + Off + + + On + + + + ..\..\..\EgtProg\EgtBEAMWALL\ISOCNC.Remoting.dll + + + + + + + + + + + + + + + + + + + + + + + + + True + Application.myapp + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + \ No newline at end of file