Modifiche core per gestione MachGroup

This commit is contained in:
Emmanuele Sassi
2021-04-12 16:35:18 +02:00
parent 463d4962e0
commit b6bced549f
21 changed files with 1315 additions and 341 deletions
@@ -255,19 +255,19 @@ Public Class BTLFeatureM
NewBTLFeature.m_ParentPart = ParentPart
NewBTLFeature.m_nFeatureId = nFeatureId
' leggo gruppo, numero feature e lato
EgtGetInfo(nFeatureId, BTL_FTR_GRP, NewBTLFeature.nSelGRP)
EgtGetInfo(nFeatureId, BTL_FTR_PRC, NewBTLFeature.nPRC)
EgtGetInfo(nFeatureId, BTL_FTR_SIDE, NewBTLFeature.nSelSIDE)
EgtGetInfo(nFeatureId, BTL_FTR_GRP, NewBTLFeature.m_nSelGRP)
EgtGetInfo(nFeatureId, BTL_FTR_PRC, NewBTLFeature.m_nPRC)
EgtGetInfo(nFeatureId, BTL_FTR_SIDE, NewBTLFeature.m_nSelSIDE)
Dim nDO As Integer = 1
If EgtGetInfo(nFeatureId, BTL_FTR_DO, nDO) Then
NewBTLFeature.bDO = (nDO <> 0)
NewBTLFeature.m_bDO = (nDO <> 0)
Else
NewBTLFeature.bDO = True
NewBTLFeature.m_bDO = True
End If
' leggo des,prid e frame
EgtGetInfo(nFeatureId, BTL_FTR_DES, NewBTLFeature.sDES)
EgtGetInfo(nFeatureId, BTL_FTR_PRID, NewBTLFeature.nPRID)
EgtGetInfo(nFeatureId, BTL_FTR_FRAME, NewBTLFeature.frFRAME)
EgtGetInfo(nFeatureId, BTL_FTR_DES, NewBTLFeature.m_sDES)
EgtGetInfo(nFeatureId, BTL_FTR_PRID, NewBTLFeature.m_nPRID)
EgtGetInfo(nFeatureId, BTL_FTR_FRAME, NewBTLFeature.m_frFRAME)
' leggo calc error
Dim nErr As Integer = 0
Dim nRot As Integer = 0
@@ -279,27 +279,27 @@ Public Class BTLFeatureM
EgtGetInfo(nFeatureId, ITG_PROJ_FALL, nFall)
EgtGetInfo(nFeatureId, ITG_PROJ_MSG, sMsg)
If Not bCalc Then
NewBTLFeature.nState = CalcStates.NOTCALCULATED
NewBTLFeature.nCALC_ERR = 0
NewBTLFeature.nCALC_ROT = 0
NewBTLFeature.nCALC_FALL = 0
NewBTLFeature.sCALC_MSG = ""
NewBTLFeature.m_nState = CalcStates.NOTCALCULATED
NewBTLFeature.m_nCALC_ERR = 0
NewBTLFeature.m_nCALC_ROT = 0
NewBTLFeature.m_nCALC_FALL = 0
NewBTLFeature.m_sCALC_MSG = ""
Else
NewBTLFeature.nCALC_ERR = nErr
NewBTLFeature.nCALC_ROT = nRot
NewBTLFeature.nCALC_FALL = nFall
NewBTLFeature.sCALC_MSG = sMsg
NewBTLFeature.m_nCALC_ERR = nErr
NewBTLFeature.m_nCALC_ROT = nRot
NewBTLFeature.m_nCALC_FALL = nFall
NewBTLFeature.m_sCALC_MSG = sMsg
If nErr = 0 Then
NewBTLFeature.nState = 0
NewBTLFeature.m_nState = 0
ElseIf nErr > 1 Then
NewBTLFeature.nState = 1
NewBTLFeature.m_nState = 1
ElseIf nErr < 1 Then
NewBTLFeature.nState = -1
NewBTLFeature.m_nState = -1
End If
End If
' leggo parametri della feature
GetBeamPrivateProfileGRPList(CalcBeamPrivateProfileGRP(NewBTLFeature.nSelGRP), NewBTLFeature.nPRC, NewBTLFeature.GRPList)
GetBeamPrivateProfileName(NewBTLFeature.nSelGRP, NewBTLFeature.nPRC, NewBTLFeature)
GetBeamPrivateProfileGRPList(CalcBeamPrivateProfileGRP(NewBTLFeature.m_nSelGRP), NewBTLFeature.m_nPRC, NewBTLFeature.m_GRPList)
GetBeamPrivateProfileName(NewBTLFeature.m_nSelGRP, NewBTLFeature.m_nPRC, NewBTLFeature)
' crea parametri per questa feature da file ini
NewBTLFeature.CreateFeatureParams(NewBTLFeature)
' leggo parametri delle feature
@@ -309,10 +309,10 @@ Public Class BTLFeatureM
Public Shared Function CreateBTLFeature(nPRC As Integer, nGRP As Integer, nSIDE As Integer) As BTLFeatureM
Dim NewBTLFeature As New BTLFeatureM
NewBTLFeature.nPRC = nPRC
NewBTLFeature.nSelGRP = nGRP
NewBTLFeature.nSelSIDE = nSIDE
NewBTLFeature.bDO = True
NewBTLFeature.m_nPRC = nPRC
NewBTLFeature.m_nSelGRP = nGRP
NewBTLFeature.m_nSelSIDE = nSIDE
NewBTLFeature.m_bDO = True
' crea parametri per questa feature da file ini
NewBTLFeature.CreateFeatureParams(NewBTLFeature)
Return NewBTLFeature
@@ -396,11 +396,11 @@ Public Class BTLFeatureM
If Not EgtGetInfo(m_nFeatureId, Param.sName, dParamValue) Then
dParamValue = 0
End If
Param.dValue = dParamValue
Param.SetValue(dParamValue)
ElseIf Param.nType = BTLParamType.STRING_ Then
Dim sParamValue As String = String.Empty
EgtGetInfo(m_nFeatureId, Param.sName, sParamValue)
Param.sValue = sParamValue
Param.SetValue(sParamValue)
ElseIf Param.nType = BTLParamType.COMBO Then
Dim nParamValue As Integer
EgtGetInfo(m_nFeatureId, Param.sName, nParamValue)
@@ -418,9 +418,9 @@ Public Class BTLFeatureM
' leggo valore parametro da struttura geometrica
For Each Param As BTLParamM In ParamList
If Param.nType = BTLParamType.DOUBLE_ Or Param.nType = BTLParamType.LENGTH Then
Param.dValue = Param.dDefault
Param.SetValue(Param.dDefault)
ElseIf Param.nType = BTLParamType.STRING_ Then
Param.sValue = ""
Param.SetValue("")
ElseIf Param.nType = BTLParamType.COMBO Then
Param.nSelValue = Param.dDefault
End If
@@ -7,7 +7,6 @@ Imports EgtWPFLib5
Public Class BTLParamM
' parametro che dice se il parametro e' P o Q
Protected m_bIsP As Boolean = True
Public ReadOnly Property bIsP As Boolean
@@ -82,6 +81,10 @@ Public Class BTLParamM
m_dValue = value
End Set
End Property
Public Sub SetValue(value As Double)
m_dValue = value
End Sub
Protected m_sValue As String
Public Overridable Property sValue As String
Get
@@ -91,6 +94,9 @@ Public Class BTLParamM
m_sValue = value
End Set
End Property
Public Sub SetValue(value As String)
m_sValue = value
End Sub
Protected m_nSelValue As Integer
Public Property nSelValue As Integer
@@ -675,7 +675,7 @@ Public Class BTLPartM
Dim sValArray() As String
Dim sValue As String = String.Empty
Dim nValue As Integer = 0
EgtGetInfo(nPartId, BTL_PRT_PDN, NewBTLPart.nPDN)
EgtGetInfo(nPartId, BTL_PRT_PDN, NewBTLPart.m_nPDN)
Dim nDO As Integer = 1
If EgtGetInfo(nPartId, BTL_PRT_DO, nDO) Then
NewBTLPart.m_bDO = (nDO <> 0)
@@ -828,22 +828,22 @@ Public Class BTLPartM
EgtGetInfo(nPartId, ITG_PROJ_FALL, nFall)
EgtGetInfo(nPartId, ITG_PROJ_MSG, sMsg)
If Not bCalc Then
NewBTLPart.nState = CalcStates.NOTCALCULATED
NewBTLPart.nCALC_ERR = -1
NewBTLPart.nCALC_ROT = 0
NewBTLPart.nCALC_FALL = 0
NewBTLPart.sCALC_MSG = ""
NewBTLPart.m_nState = CalcStates.NOTCALCULATED
NewBTLPart.m_nCALC_ERR = -1
NewBTLPart.m_nCALC_ROT = 0
NewBTLPart.m_nCALC_FALL = 0
NewBTLPart.m_sCALC_MSG = ""
Else
NewBTLPart.nCALC_ERR = nErr
NewBTLPart.nCALC_ROT = nRot
NewBTLPart.nCALC_FALL = nFall
NewBTLPart.sCALC_MSG = sMsg
NewBTLPart.m_nCALC_ERR = nErr
NewBTLPart.m_nCALC_ROT = nRot
NewBTLPart.m_nCALC_FALL = nFall
NewBTLPart.m_sCALC_MSG = sMsg
If nErr = 0 Then
NewBTLPart.nState = CalcStates.OK
NewBTLPart.m_nState = CalcStates.OK
ElseIf nErr > 1 Then
NewBTLPart.nState = CalcStates.ERROR_
NewBTLPart.m_nState = CalcStates.ERROR_
ElseIf nErr < 1 Then
NewBTLPart.nState = CalcStates.NOTCALCULATED
NewBTLPart.m_nState = CalcStates.NOTCALCULATED
End If
End If
Return NewBTLPart
@@ -418,6 +418,13 @@ Public Class BTLStructureM
End If
End Sub
Public Sub RemoveBTLPart(BTLPartM As BTLPartM)
If IsNothing(BTLPartM) Then Return
If Not m_BTLPartMList.Contains(BTLPartM) Then Return
m_BTLPartMList.Remove(BTLPartM)
'RaiseEvent BTLPartAdded(Me, New BTLPartAddedEventArgs(BTLPartM))
End Sub
Public Function GetBTLParts() As List(Of BTLPartM)
Return New List(Of BTLPartM)(m_BTLPartMList)
End Function
-39
View File
@@ -1,39 +0,0 @@
Imports System.Collections.ObjectModel
Imports System.IO
Imports EgtUILib
Imports EgtWPFLib5
Public Class Beam
Inherits PartM
Protected m_dOffset As Double
Public ReadOnly Property dOffset As Double
Get
Return m_dOffset
End Get
End Property
' Id del grezzo
Protected m_nRawPartId As Integer = GDB_ID.NULL
#Region "CONSTRUCTOR"
Sub New(nParentMachGroup As Core.MyMachGroupM, nPartId As Integer, nRawPartId As Integer)
MyBase.New(nParentMachGroup, nPartId)
m_nRawPartId = nRawPartId
End Sub
#End Region ' CONSTRUCTOR
Friend Sub UpdateOffset()
' calcolo offset
Dim nBeamIndex As Integer = ParentMachGroup.PartList.IndexOf(Me)
If nBeamIndex > 0 Then
m_dOffset = dPOSX - (ParentMachGroup.PartList(nBeamIndex - 1).dPOSX + ParentMachGroup.PartList(nBeamIndex - 1).dL)
Else
Dim BeamMachGroup As BeamMachGroup = DirectCast(ParentMachGroup, BeamMachGroup)
m_dOffset = BeamMachGroup.dStartCut
End If
End Sub
End Class
+108
View File
@@ -0,0 +1,108 @@
Imports System.Collections.ObjectModel
Imports System.IO
Imports EgtUILib
Imports EgtWPFLib5
Public Class BeamM
Inherits PartM
Protected m_dOffset As Double
Public Property dOffset As Double
Get
Return m_dOffset
End Get
Set(value As Double)
m_dOffset = value
End Set
End Property
' Id del grezzo
Protected m_nRawPartId As Integer = GDB_ID.NULL
'#Region "CONSTRUCTOR"
' Sub New(nParentMachGroup As MyMachGroupM, nPartId As Integer, nRawPartId As Integer)
' MyBase.New(nParentMachGroup, nPartId)
' m_nRawPartId = nRawPartId
' End Sub
'#End Region ' CONSTRUCTOR
#Region "CONSTRUCTORS"
Protected Sub New(nParentMachGroup As MyMachGroupM, nPartId As Integer)
MyBase.New(nParentMachGroup, nPartId)
End Sub
'Public Shared Function CreateNewBeam() As BeamM
' Return New BeamM
'End Function
Public Shared Function CreateBeam(nParentMachGroup As MyMachGroupM, nPartId As Integer, nRawPartId As Integer) As BeamM
Dim NewBeamM As New BeamM(nParentMachGroup, nPartId)
NewBeamM.m_nRawPartId = nRawPartId
' leggo info pezzo
EgtGetInfo(nPartId, BTL_PRT_PROJ, NewBeamM.nProjId)
EgtGetInfo(nPartId, BTL_PRT_PDN, NewBeamM.nPDN)
EgtGetInfo(nPartId, BTL_PRT_NAM, NewBeamM.sNAM)
EgtGetInfo(nPartId, BTL_PRT_L, NewBeamM.dL)
EgtGetInfo(nPartId, BTL_PRT_W, NewBeamM.dW)
EgtGetInfo(nPartId, BTL_PRT_H, NewBeamM.dH)
EgtGetInfo(nPartId, BTL_PRT_CNT, NewBeamM.nCNT)
Dim nTemp As Integer = 0
If Not EgtGetInfo(nPartId, BTL_PRT_ROTATED, nTemp) Then
nTemp = 0
End If
NewBeamM.SetRotated(nTemp)
If Not EgtGetInfo(nPartId, BTL_PRT_INVERTED, nTemp) Then
nTemp = 0
End If
NewBeamM.SetInverted(nTemp)
' leggo PosX
Dim sInfo As String = ""
Dim Index = 1
Dim sSplitInfo() As String
Dim bFound As Boolean = False
While EgtGetInfo(NewBeamM.m_ParentMachGroup.Id, MGR_RPT_PART & Index, sInfo)
If Not String.IsNullOrWhiteSpace(sInfo) Then
sSplitInfo = sInfo.Split(","c)
If sSplitInfo(0) = nPartId Then
bFound = True
Exit While
End If
End If
Index += 1
End While
If bFound Then
StringToDouble(sSplitInfo(1), NewBeamM.dPOSX)
End If
' leggo feature
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
' creo la feature
'''FeatureList.Add(New BTLFeatureVM(Nothing, nFeatureId))
End If
nFeatureId = EgtGetNext(nFeatureId)
End While
Return NewBeamM
End Function
#End Region ' CONSTRUCTORS
Friend Sub UpdateOffset()
' calcolo offset
Dim nBeamIndex As Integer = ParentMachGroup.PartMList.IndexOf(Me)
If nBeamIndex > 0 Then
m_dOffset = dPOSX - (ParentMachGroup.PartMList(nBeamIndex - 1).dPOSX + ParentMachGroup.PartMList(nBeamIndex - 1).dL)
Else
Dim BeamMachGroup As BeamMachGroupM = DirectCast(ParentMachGroup, BeamMachGroupM)
m_dOffset = BeamMachGroup.dStartCut
End If
End Sub
End Class
-60
View File
@@ -1,60 +0,0 @@
Imports System.Collections.ObjectModel
Imports System.IO
Imports EgtUILib
Imports EgtWPFLib5
Public Class BeamMachGroup
Inherits MyMachGroupM
Protected m_dStartCut As Double
Public ReadOnly Property dStartCut As Double
Get
Return m_dStartCut
End Get
End Property
Sub New(nId As Integer, sName As String, sMachine As String)
MyBase.New(nId, sName, sMachine)
SetMachineType(MachineType.BEAM)
EgtGetInfo(nId, MGR_RPT_BARLEN, dL)
EgtGetInfo(nId, MGR_RPT_BARHEIGHT, dH)
EgtGetInfo(nId, MGR_RPT_BARWIDTH, dW)
m_dTotMat = dL
For Each Part In PartList
m_dMatForPart += Part.dL
Next
End Sub
Public Overrides Sub RefreshPartList()
' leggo StartCut da posizione primo pezzo
Dim sInfo As String = ""
Dim sSplitInfo() As String
Dim bFound As Boolean = False
EgtGetInfo(Id, MGR_RPT_PART & 1, sInfo)
If Not String.IsNullOrWhiteSpace(sInfo) Then
sSplitInfo = sInfo.Split(","c)
StringToDouble(sSplitInfo(1), m_dStartCut)
Else
m_dStartCut = 0
End If
' aggiorno lista pezzi
PartList.Clear()
Dim nRawPartId As Integer = EgtGetFirstRawPart()
While nRawPartId <> GDB_ID.NULL
Dim nPartId As Integer = EgtGetFirstPartInRawPart(nRawPartId)
If nPartId <> GDB_ID.NULL Then
Dim NewBeam As Beam = New Beam(Me, nPartId, nRawPartId)
PartList.Add(NewBeam)
NewBeam.UpdateOffset()
End If
nRawPartId = EgtGetNextRawPart(nRawPartId)
End While
End Sub
Public Overrides Sub RefreshGroupData()
EgtGetInfo(Id, MGR_RPT_BARLEN, dL)
EgtGetInfo(Id, MGR_RPT_BARHEIGHT, dH)
EgtGetInfo(Id, MGR_RPT_BARWIDTH, dW)
End Sub
End Class
+1
View File
@@ -116,6 +116,7 @@
Friend Const BTLINFO As String = "BtlInfo"
' info parametri BTL
Friend Const BTL_PRT_PROJ As String = "PROJ"
Friend Const BTL_PRT_PDN As String = "PDN"
Friend Const BTL_PRT_DO As String = "DO"
Friend Const BTL_PRT_NAM As String = "NAM"
@@ -0,0 +1,18 @@
Public Class PartAddedEventArgs
Inherits EventArgs
Public m_NewPart As PartM
Public Property NewPart As PartM
Get
Return m_NewPart
End Get
Private Set(value As PartM)
m_NewPart = value
End Set
End Property
Sub New(NewBTLFeature As PartM)
Me.NewPart = NewBTLFeature
End Sub
End Class
+15 -7
View File
@@ -71,15 +71,19 @@
<Import Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="Beam.vb" />
<Compile Include="BeamMachGroup.vb" />
<Compile Include="BeamM.vb" />
<Compile Include="MachGroup Model\BeamMachGroupM.vb" />
<Compile Include="DataAccess\PartAddedEventArgs.vb" />
<Compile Include="DataAccess\BTLParamAddedEventArgs.vb" />
<Compile Include="Model\BTLFeatureM.vb" />
<Compile Include="Model\BTLParamM.vb" />
<Compile Include="Lib\MachGroupAddedEventArgs.vb" />
<Compile Include="Lib\MachGroupVM.vb" />
<Compile Include="Lib\NewMachGroupPanelVM.vb" />
<Compile Include="BTL Model\BTLFeatureM.vb" />
<Compile Include="BTL Model\BTLParamM.vb" />
<Compile Include="DataAccess\BTLFeatureAddedEventArgs.vb" />
<Compile Include="DataAccess\BTLPartAddedEventArgs.vb" />
<Compile Include="Model\BTLPartM.vb" />
<Compile Include="Model\BTLStructureM.vb" />
<Compile Include="BTL Model\BTLPartM.vb" />
<Compile Include="BTL Model\BTLStructureM.vb" />
<Compile Include="Constants\ConstBeam.vb" />
<Compile Include="Enum.vb" />
<Compile Include="My Project\AssemblyInfo.vb" />
@@ -97,7 +101,11 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="MyMachGroupM.vb" />
<Compile Include="MachGroup Model\MyMachGroupM.vb" />
<Compile Include="Lib\MachGroupM.vb" />
<Compile Include="Lib\MachGroupPanelM.vb" />
<Compile Include="MachGroup Model\MyMachGroupPanelM.vb" />
<Compile Include="MyMachine.vb" />
<Compile Include="PartM.vb" />
<Compile Include="ProdFileM.vb" />
<Compile Include="ProjectFileM.vb" />
@@ -0,0 +1,18 @@
Public Class MachGroupAddedEventArgs
Inherits EventArgs
Public m_NewMachGroupM As MachGroupM
Public Property NewMachGroupM As MachGroupM
Get
Return m_NewMachGroupM
End Get
Private Set(value As MachGroupM)
m_NewMachGroupM = value
End Set
End Property
Sub New(NewMachGroupM As MachGroupM)
Me.NewMachGroupM = NewMachGroupM
End Sub
End Class
+69
View File
@@ -0,0 +1,69 @@
Imports System.Collections.ObjectModel
Imports System.IO
Imports System.Windows
Imports EgtUILib
Imports EgtWPFLib5
Public Class MachGroupM
Protected m_Id As Integer
Public ReadOnly Property Id As Integer
Get
Return m_Id
End Get
End Property
Protected m_Name As String
Public ReadOnly Property Name As String
Get
Return m_Name
End Get
End Property
Protected m_Machine As String
Public ReadOnly Property Machine As String
Get
Return m_Machine
End Get
End Property
Protected m_IsEnabled As Boolean
Public Property IsEnabled As Boolean
Get
Return m_IsEnabled
End Get
Set(value As Boolean)
m_IsEnabled = value
End Set
End Property
#Region "CONSTRUCTORS"
Protected Sub New()
End Sub
Public Shared Function CreateNewMachGroup() As MachGroupM
Return New MachGroupM
End Function
Public Shared Function CreateMachGroup(nId As Integer, sName As String, sMachine As String) As MachGroupM
Dim NewMachGroupM As New MachGroupM
NewMachGroupM.m_Id = nId
NewMachGroupM.m_Name = sName
NewMachGroupM.m_Machine = sMachine
Return NewMachGroupM
End Function
Public Shared Function CreateMachGroup(sName As String, sMachine As String) As MachGroupM
Dim NewMachGroupM As New MachGroupM
' Creo il nuovo gruppo di lavorazione con i dati ottenuti a seconda del caso in cui mi trovo
NewMachGroupM.m_Id = EgtAddMachGroup(sName, sMachine)
If NewMachGroupM.m_Id = GDB_ID.NULL Then Return Nothing
NewMachGroupM.m_Name = sName
NewMachGroupM.m_Machine = sMachine
Return NewMachGroupM
End Function
#End Region ' CONSTRUCTORS
End Class
+243
View File
@@ -0,0 +1,243 @@
Imports System.Collections.ObjectModel
Imports System.IO
Imports System.Windows
Imports EgtUILib
Imports EgtWPFLib5
Public Class MachGroupPanelM
#Region "FIELDS & PROPERTIES"
' Lista delle macchine disponibili
Protected m_MachineList As List(Of Machine)
' Macchina di default
Protected m_DefaultMachine As String = String.Empty
Public ReadOnly Property DefaultMachine As String
Get
Return m_DefaultMachine
End Get
End Property
' Variabile che definisce se il nome è automatico
Protected m_IsGroupNameAutomatic As Boolean = True
' Variabile che definisce se ci sono più gruppi di lavorazione
Protected m_IsMultiMachGroup As Boolean
Public ReadOnly Property IsMultiMachGroup As Boolean
Get
Return m_IsMultiMachGroup
End Get
End Property
' Nome base dei gruppi
Protected m_BaseName As String
Protected m_MachGroupMList As New List(Of MachGroupM)
Public Property MachGroupMList As List(Of MachGroupM)
Get
Return m_MachGroupMList
End Get
Set(value As List(Of MachGroupM))
m_MachGroupMList = value
End Set
End Property
Protected m_MachGroupPanel_Visibility As Visibility
Public Property MachGroupPanel_Visibility As Visibility
Get
Return m_MachGroupPanel_Visibility
End Get
Set(value As Visibility)
m_MachGroupPanel_Visibility = value
End Set
End Property
' Variabile che permette di abilitare/disabilitare i bottoni aggiungi e togli MachGroup
Protected m_IsEnabledAddRemove As Boolean
Public Property IsEnabledAddRemove As Boolean
Get
Return m_IsEnabledAddRemove
End Get
Set(value As Boolean)
m_IsEnabledAddRemove = value
End Set
End Property
' Variabile che definisce lo stato (attivi/disattivi) di tutti i gruppi tranne quello selezionato
Protected m_IsEnabledMachGroups As Boolean
Public Property IsEnabledMachGroups As Boolean
Get
Return m_IsEnabledMachGroups
End Get
Set(value As Boolean)
m_IsEnabledMachGroups = value
End Set
End Property
#End Region ' FIELDS & PROPERTIES
#Region "CONSTRUCTOR"
Protected Sub New()
End Sub
Public Shared Function CreateNewMachGroupPanel() As MachGroupPanelM
Return New MachGroupPanelM
End Function
Public Shared Function CreateMachGroupPanel(IsMultiMachGroup As Boolean,
MachineList As List(Of Machine), DefaultMachine As String,
Optional sBaseName As String = "MachGroup_1") As MachGroupPanelM
Dim NewMachGroupPanelM As New MachGroupPanelM
NewMachGroupPanelM.m_IsMultiMachGroup = IsMultiMachGroup
' Assegno nome base
NewMachGroupPanelM.m_BaseName = sBaseName
' Recupero lista macchine
NewMachGroupPanelM.m_MachineList = MachineList
' Assegno macchina di default
NewMachGroupPanelM.m_DefaultMachine = DefaultMachine
' recupero i MachGroup
NewMachGroupPanelM.m_MachGroupMList = LoadMachGroups()
Return NewMachGroupPanelM
End Function
Public Shared Function LoadMachGroups() As List(Of MachGroupM)
Dim TempList As New List(Of MachGroupM)
Dim nId = EgtGetFirstMachGroup()
While nId <> GDB_ID.NULL
EgtSetCurrMachGroup(nId)
Dim sName As String = String.Empty
Dim sMachine As String = String.Empty
EgtGetMachGroupName(nId, sName)
EgtGetMachGroupMachineName(nId, sMachine)
TempList.Add(MachGroupM.CreateMachGroup(nId, sName, sMachine))
nId = EgtGetNextMachGroup(nId)
End While
Return TempList
End Function
#End Region ' CONSTRUCTOR
#Region "METHODS"
Public Event MachGroupAdded As EventHandler(Of MachGroupAddedEventArgs)
Public Overridable Sub AddMachGroup(MachGroupM As MachGroupM)
If IsNothing(MachGroupM) Then Return
If Not m_MachGroupMList.Contains(MachGroupM) Then
m_MachGroupMList.Add(MachGroupM)
RaiseEvent MachGroupAdded(Me, New MachGroupAddedEventArgs(MachGroupM))
End If
End Sub
Public Function GetMachGroups() As List(Of MachGroupM)
Return New List(Of MachGroupM)(m_MachGroupMList)
End Function
'Public Function InitMachGroupPanel(IsMultiMachGroup As Boolean,
' MachineList As List(Of Machine), DefaultMachine As String,
' Optional sBaseName As String = "MachGroup_1") As Boolean
' m_IsMultiMachGroup = IsMultiMachGroup
' ' se è a gruppo singolo, nascondo il panel
' If Not m_IsMultiMachGroup Then SetMachGroupPanelVisibility(False)
' ' Assegno nome base
' m_BaseName = sBaseName
' ' Recupero lista macchine
' m_MachineList = MachineList
' ' Assegno macchina di default
' m_DefaultMachine = DefaultMachine
' Return MachineList.Count > 0
'End Function
'Public Overridable Sub LoadMachGroupList()
' ' Carico i gruppi di lavorazione nella lista
' Dim nId = EgtGetFirstMachGroup()
' While nId <> GDB_ID.NULL
' Dim sName As String = String.Empty
' Dim sMachine As String = String.Empty
' EgtGetMachGroupName(nId, sName)
' EgtGetMachGroupMachineName(nId, sMachine)
' MachGroupMList.Add(New MachGroup(nId, sName, sMachine))
' nId = EgtGetNextMachGroup(nId)
' End While
'End Sub
Public Overridable Function NewMachGroup() As MachGroupM
' Sistemazioni preliminari
OnPreNewMachGroup()
' Se non ci sono macchine disponibili esco con errore
If m_MachineList.Count <= 0 Then Return Nothing
' Creo il VM per chiedere nome e macchina a seconda del caso in cui mi trovo
Dim NewMachGroupWndVM As NewMachGroupWndVM = Nothing
Dim sNewMGrpName As String = m_BaseName
Dim sNewMachName As String = m_MachineList(0).Name
If m_IsMultiMachGroup Then
EgtGetMachGroupNewName(sNewMGrpName)
If m_MachineList.Count = 1 Then
If Not m_IsGroupNameAutomatic Then
NewMachGroupWndVM = New NewMachGroupWndVM(sNewMGrpName)
End If
Else
If m_IsGroupNameAutomatic Then
NewMachGroupWndVM = New NewMachGroupWndVM(m_DefaultMachine, m_MachineList)
Else
NewMachGroupWndVM = New NewMachGroupWndVM(sNewMGrpName, m_DefaultMachine, m_MachineList)
End If
End If
ElseIf EgtGetMachGroupCount() = 0 Then
If m_MachineList.Count > 1 Then
NewMachGroupWndVM = New NewMachGroupWndVM(m_DefaultMachine, m_MachineList)
End If
End If
' Se necessario, lancio finestra di acquisizione dati
If Not IsNothing(NewMachGroupWndVM) Then
' Se non esistono gruppi nella lista, rendo la finestra non chiudibile senza scelta
If m_MachGroupMList.Count = 0 Then NewMachGroupWndVM.IsClosable = False
' Lancio finestra
Dim NewMachGroupWndV As New NewMachGroupWndV(Application.Current.MainWindow, NewMachGroupWndVM)
If NewMachGroupWndV.ShowDialog() = False Then Return Nothing
' Recupero dati
If Not IsNothing(NewMachGroupWndVM.Name) Then sNewMGrpName = NewMachGroupWndVM.Name
If Not IsNothing(NewMachGroupWndVM.SelectedMachine) Then sNewMachName = NewMachGroupWndVM.SelectedMachine.Name
End If
' Creo il nuovo gruppo di lavorazione con i dati ottenuti a seconda del caso in cui mi trovo
Dim MachGroupM As MachGroupM = MachGroupM.CreateMachGroup(sNewMGrpName, sNewMachName)
If IsNothing(MachGroupM) Then Return Nothing
AddMachGroup(MachGroupM)
' Sistemazioni finali
m_DefaultMachine = sNewMachName
OnPostNewMachGroup()
Return MachGroupM
End Function
Public Function NewMachGroupWithDefaults() As MachGroupM
' Sistemazioni preliminari
OnPreNewMachGroup()
' Se non ci sono macchine disponibili esco con errore
If m_MachineList.Count <= 0 Then Return Nothing
' Assegno valori di default
Dim sNewMGrpName As String = m_BaseName
Dim sNewMachName As String = If(Machine.ExistsMachine(m_DefaultMachine, m_MachineList), m_DefaultMachine, m_MachineList(0).Name)
' Creo il nuovo gruppo di lavorazione con i dati ottenuti a seconda del caso in cui mi trovo
Dim MachGroupM As MachGroupM = MachGroupM.CreateMachGroup(sNewMGrpName, sNewMachName)
If IsNothing(MachGroupM) Then Return Nothing
AddMachGroup(MachGroupM)
' Sistemazioni finali
m_DefaultMachine = sNewMachName
OnPostNewMachGroup()
Return MachGroupM
End Function
Public Overridable Function OnPreNewMachGroup() As Boolean
Return True
End Function
Public Overridable Function OnPostNewMachGroup() As Boolean
Return True
End Function
Public Overridable Function OnPreRemoveCurrMachGroup() As Boolean
Return True
End Function
#End Region ' METHODS
End Class
+60
View File
@@ -0,0 +1,60 @@
Imports System.Collections.ObjectModel
Imports System.IO
Imports System.Windows
Imports EgtUILib
Imports EgtWPFLib5
Public Class MachGroupVM
Inherits VMBase
Protected m_MachGroupM As MachGroupM
Public ReadOnly Property MachGroupM As MachGroupM
Get
Return m_MachGroupM
End Get
End Property
Public ReadOnly Property Id As Integer
Get
Return m_MachGroupM.Id
End Get
End Property
Public ReadOnly Property Name As String
Get
Return m_MachGroupM.Name
End Get
End Property
Public ReadOnly Property Machine As String
Get
Return m_MachGroupM.Machine
End Get
End Property
Public Property IsEnabled As Boolean
Get
Return m_MachGroupM.IsEnabled
End Get
Set(value As Boolean)
m_MachGroupM.IsEnabled = value
NotifyPropertyChanged(NameOf(IsEnabled))
End Set
End Property
#Region "ToolTip"
Public Overridable ReadOnly Property MachGroupToolTip As String
Get
Return "Name: " & m_MachGroupM.Name & Environment.NewLine &
"Machine: " & m_MachGroupM.Machine
End Get
End Property
#End Region ' ToolTip
Sub New(MachGroupM As MachGroupM)
m_MachGroupM = MachGroupM
End Sub
End Class
+290
View File
@@ -0,0 +1,290 @@
Imports System.Collections.ObjectModel
Imports System.Collections.Specialized
Imports System.ComponentModel
Imports System.IO
Imports System.Windows
Imports System.Windows.Input
Imports EgtBEAMWALL.Core
Imports EgtUILib
Imports EgtWPFLib5
Public Class NewMachGroupPanelVM
Inherits VMBase
#Region "FIELDS & PROPERTIES"
Protected m_MachGroupPanelM As MachGroupPanelM
Public ReadOnly Property DefaultMachine As String
Get
Return m_MachGroupPanelM.DefaultMachine
End Get
End Property
Private m_MachGroupVMList As ObservableCollection(Of MachGroupVM)
Public Property MachGroupVMList As ObservableCollection(Of MachGroupVM)
Get
Return m_MachGroupVMList
End Get
Set(value As ObservableCollection(Of MachGroupVM))
m_MachGroupVMList = value
End Set
End Property
Private m_SelectedMachGroup As MachGroupVM
Public Property SelectedMachGroup As MachGroupVM
Get
Return m_SelectedMachGroup
End Get
Set(value As MachGroupVM)
m_SelectedMachGroup = value
If Not IsNothing(value) Then
OnPreSetCurrMachGroup()
EgtSetCurrMachGroup(value.Id)
OnPostSetCurrMachGroup()
End If
NotifyPropertyChanged(NameOf(SelectedMachGroup))
End Set
End Property
Public ReadOnly Property MachGroupPanel_Visibility As Visibility
Get
Return m_MachGroupPanelM.MachGroupPanel_Visibility
End Get
End Property
Public Sub SetMachGroupPanelVisibility(IsVisible As Boolean)
If IsVisible Then
m_MachGroupPanelM.MachGroupPanel_Visibility = Visibility.Visible
Else
m_MachGroupPanelM.MachGroupPanel_Visibility = Visibility.Collapsed
End If
NotifyPropertyChanged(NameOf(MachGroupPanel_Visibility))
End Sub
' Variabile che permette di abilitare/disabilitare i bottoni aggiungi e togli MachGroup
Public Property IsEnabledAddRemove As Boolean
Get
Return m_MachGroupPanelM.IsEnabledAddRemove
End Get
Set(value As Boolean)
m_MachGroupPanelM.IsEnabledAddRemove = value
NotifyPropertyChanged(NameOf(IsEnabledAddRemove))
End Set
End Property
' Variabile che definisce lo stato (attivi/disattivi) di tutti i gruppi tranne quello selezionato
Public ReadOnly Property IsEnabledMachGroups As Boolean
Get
Return m_MachGroupPanelM.IsEnabledMachGroups
End Get
End Property
' Definizione comandi
Private m_cmdSetCurrMachGroup As ICommand
Private m_cmdAddMachGroup As ICommand
Private m_cmdRemoveMachGroup As ICommand
#End Region ' FIELDS & PROPERTIES
#Region "CONSTRUCTOR"
Sub New(MachGroupPanelM As MachGroupPanelM)
m_MachGroupPanelM = MachGroupPanelM
AddHandler m_MachGroupPanelM.MachGroupAdded, AddressOf OnMachGroupAdded
If Not MachGroupPanelM.IsMultiMachGroup Then SetMachGroupPanelVisibility(False)
CreateMachGroupVMList()
' Creo riferimento a questa classe in LibMap
'''LibMap.SetRefMachGroupPanelVM(Me)
End Sub
#End Region ' CONSTRUCTOR
#Region "METHODS"
Protected Overridable Sub CreateMachGroupVMList()
Dim all As List(Of MachGroupVM) = (From MachGroupM In m_MachGroupPanelM.GetMachGroups()
Select New MachGroupVM(MachGroupM)).ToList()
For Each MachGroupvM As MachGroupVM In all
AddHandler MachGroupvM.PropertyChanged, AddressOf OnMachGroupVMPropertyChanged
Next
m_MachGroupVMList = New ObservableCollection(Of MachGroupVM)(all)
AddHandler m_MachGroupVMList.CollectionChanged, AddressOf OnMachGroupVMListChanged
End Sub
Public Overridable Function InitMachGroupList(Optional bUseDefaults As Boolean = False) As Boolean
' Svuoto precedente lista di MachGroup
m_MachGroupPanelM.MachGroupMList.Clear()
' verifico se esistono già gruppi di lavorazione o se devo creare il primo
Dim bOk As Boolean
Dim nId = EgtGetFirstMachGroup()
If nId <> GDB_ID.NULL Then
bOk = EgtSetCurrMachGroup(nId)
Else
If bUseDefaults Then
bOk = Not IsNothing(m_MachGroupPanelM.NewMachGroupWithDefaults())
Else
bOk = Not IsNothing(m_MachGroupPanelM.NewMachGroup())
End If
End If
If Not bOk Then Return False
' Sistemazioni finali
m_MachGroupPanelM.MachGroupMList = MachGroupPanelM.LoadMachGroups()
SelectedMachGroup = MachGroupVMList(0)
Return True
End Function
' Funzione che permette di abilitare o disabilitare tutti i gruppi tranne quello selezionato più i bottni Add/Remove
Public Function SetMachGroupState(bState As Boolean) As Boolean
If bState Then
For Each Group In MachGroupVMList
Group.IsEnabled = True
Next
m_MachGroupPanelM.IsEnabledAddRemove = True
NotifyPropertyChanged(NameOf(IsEnabledAddRemove))
m_MachGroupPanelM.IsEnabledMachGroups = True
Return True
Else
For Each Group In MachGroupVMList
If Group Is SelectedMachGroup Then
Group.IsEnabled = True
Else
Group.IsEnabled = False
End If
Next
m_MachGroupPanelM.IsEnabledAddRemove = False
NotifyPropertyChanged(NameOf(IsEnabledAddRemove))
m_MachGroupPanelM.IsEnabledMachGroups = False
Return True
End If
Return False
End Function
Public Overridable Function OnPreSetCurrMachGroup() As Boolean
Return True
End Function
Public Overridable Function OnPostSetCurrMachGroup() As Boolean
Return True
End Function
#End Region ' METHODS
#Region "COMMANDS"
#Region "AddMachGroupCommand"
''' <summary>
''' Returns a command that set the selected MachGroup as the Current one.
''' </summary>
Public ReadOnly Property AddMachGroupCommand As ICommand
Get
If m_cmdAddMachGroup Is Nothing Then
m_cmdAddMachGroup = New Command(AddressOf AddMachGroup)
End If
Return m_cmdAddMachGroup
End Get
End Property
Public Overridable Sub AddMachGroup()
Dim MachGroupM As MachGroupM = m_MachGroupPanelM.NewMachGroup()
If IsNothing(MachGroupM) Then Return
' lo seleziono
SelectedMachGroup = MachGroupVMList.FirstOrDefault(Function(x) x.MachGroupM Is MachGroupM)
EgtZoom(ZM.ALL)
End Sub
#End Region ' AddMachGroupCommand
#Region "RemoveMachGroupCommand"
''' <summary>
''' Returns a command that set the selected MachGroup as the Current one.
''' </summary>
Public ReadOnly Property RemoveMachGroupCommand As ICommand
Get
If m_cmdRemoveMachGroup Is Nothing Then
m_cmdRemoveMachGroup = New Command(AddressOf RemoveMachGroup)
End If
Return m_cmdRemoveMachGroup
End Get
End Property
Public Overridable Sub RemoveMachGroup()
' Calcolo indice del gruppo da cancellare
Dim nSelectedMachGroupIndex As Integer = MachGroupVMList.IndexOf(SelectedMachGroup)
If MachGroupVMList.Count = 1 Then
'chiedo conferma prima di resettare il gruppo di lavorazione
Select Case MessageBox.Show("Eliminare?", "", MessageBoxButton.YesNo, MessageBoxImage.Question)
Case MessageBoxResult.Yes
' cancello il gruppo corrente e ne creo uno nuovo con lo stesso nome
m_MachGroupPanelM.OnPreRemoveCurrMachGroup()
EgtRemoveMachGroup(MachGroupVMList(0).Id)
MachGroupVMList.Clear()
AddMachGroup()
EgtZoom(ZM.ALL)
Case MessageBoxResult.No
Return
End Select
Else
'chiedo conferma prima di cancellare il gruppo di lavorazione
Select Case MessageBox.Show("Eliminare?", "", MessageBoxButton.YesNo, MessageBoxImage.Question)
Case MessageBoxResult.Yes
' cancello quello selezionato (ovvero il corrente)
m_MachGroupPanelM.OnPreRemoveCurrMachGroup()
EgtRemoveMachGroup(MachGroupVMList(nSelectedMachGroupIndex).Id)
' rendo corrente il gruppo di lavorazione successivo a quello da cancellare
If nSelectedMachGroupIndex = 0 And MachGroupVMList.Count > 1 Then
EgtSetCurrMachGroup(MachGroupVMList(nSelectedMachGroupIndex + 1).Id)
SelectedMachGroup = MachGroupVMList(nSelectedMachGroupIndex + 1)
' rendo corrente il gruppo di lavorazione precedente a quello da cancellare
ElseIf nSelectedMachGroupIndex > 0 Then
EgtSetCurrMachGroup(MachGroupVMList(nSelectedMachGroupIndex - 1).Id)
SelectedMachGroup = MachGroupVMList(nSelectedMachGroupIndex - 1)
End If
EgtZoom(ZM.ALL)
' aggiorno la lista dei gruppi
MachGroupVMList.RemoveAt(nSelectedMachGroupIndex)
Case MessageBoxResult.No
Return
End Select
End If
End Sub
#End Region ' RemoveMachGroupCommand
#End Region ' COMMANDS
#Region "EVENTS"
Protected Overridable Sub OnMachGroupAdded(sender As Object, e As MachGroupAddedEventArgs)
Dim MachGroupVM As MachGroupVM = New MachGroupVM(e.NewMachGroupM)
m_MachGroupVMList.Add(MachGroupVM)
NotifyPropertyChanged(NameOf(MachGroupVMList))
End Sub
Protected Sub OnMachGroupVMListChanged(sender As Object, e As NotifyCollectionChangedEventArgs)
If Not IsNothing(e.NewItems) AndAlso e.NewItems.Count > 0 Then
For Each MachGroupVM As MachGroupVM In e.NewItems
AddHandler MachGroupVM.PropertyChanged, AddressOf OnMachGroupVMPropertyChanged
Next
End If
If Not IsNothing(e.OldItems) AndAlso e.OldItems.Count > 0 Then
For Each MachGroupVM As MachGroupVM In e.OldItems
RemoveHandler MachGroupVM.PropertyChanged, AddressOf OnMachGroupVMPropertyChanged
Next
End If
End Sub
Protected Overridable Sub OnMachGroupVMPropertyChanged(sender As Object, e As PropertyChangedEventArgs)
Select Case e.PropertyName
'Case nameof(sender.sMATERIAL)
End Select
End Sub
#End Region ' EVENTS
End Class
@@ -0,0 +1,112 @@
Imports System.Collections.ObjectModel
Imports System.IO
Imports EgtUILib
Imports EgtWPFLib5
Public Class BeamMachGroupM
Inherits MyMachGroupM
Protected m_dStartCut As Double
Public Property dStartCut As Double
Get
Return m_dStartCut
End Get
Set(value As Double)
m_dStartCut = value
End Set
End Property
#Region "CONSTRUCTORS"
Protected Sub New()
End Sub
Public Shared Function CreateNewBeamMachGroup() As MachGroupM
Return New MachGroupM
End Function
Public Shared Function CreateBeamMachGroup(nId As Integer, sName As String, sMachine As String) As MachGroupM
Dim NewMachGroupM As New BeamMachGroupM
NewMachGroupM.m_Id = nId
NewMachGroupM.m_Name = sName
NewMachGroupM.m_Machine = sMachine
NewMachGroupM.SetMachineType(MachineType.BEAM)
EgtGetInfo(NewMachGroupM.m_Id, MGR_RPT_BARLEN, NewMachGroupM.m_dL)
EgtGetInfo(NewMachGroupM.m_Id, MGR_RPT_BARHEIGHT, NewMachGroupM.m_dH)
EgtGetInfo(NewMachGroupM.m_Id, MGR_RPT_BARWIDTH, NewMachGroupM.m_dW)
NewMachGroupM.m_dTotMat = NewMachGroupM.m_dL
NewMachGroupM.m_PartMList = LoadParts(NewMachGroupM)
For Each Part In NewMachGroupM.m_PartMList
NewMachGroupM.m_dMatForPart += Part.dL
Next
Return NewMachGroupM
End Function
Public Shared Function CreateBeamMachGroup(sName As String, sMachine As String) As MachGroupM
Dim NewMachGroupM As New BeamMachGroupM
' Creo il nuovo gruppo di lavorazione con i dati ottenuti a seconda del caso in cui mi trovo
NewMachGroupM.m_Id = EgtAddMachGroup(sName, sMachine)
If NewMachGroupM.m_Id = GDB_ID.NULL Then Return Nothing
NewMachGroupM.m_Name = sName
NewMachGroupM.m_Machine = sMachine
NewMachGroupM.SetMachineType(MachineType.BEAM)
EgtGetInfo(NewMachGroupM.m_Id, MGR_RPT_BARLEN, NewMachGroupM.m_dL)
EgtGetInfo(NewMachGroupM.m_Id, MGR_RPT_BARHEIGHT, NewMachGroupM.m_dH)
EgtGetInfo(NewMachGroupM.m_Id, MGR_RPT_BARWIDTH, NewMachGroupM.m_dW)
NewMachGroupM.m_dTotMat = NewMachGroupM.m_dL
For Each Part In NewMachGroupM.m_PartMList
NewMachGroupM.m_dMatForPart += Part.dL
Next
Return NewMachGroupM
End Function
#End Region ' CONSTRUCTORS
Private Shared Function LoadParts(NewBeamMachGroupM As BeamMachGroupM) As List(Of PartM)
Dim TempList As New List(Of PartM)
Dim nRawPartId As Integer = EgtGetFirstRawPart()
While nRawPartId <> GDB_ID.NULL
Dim nPartId As Integer = EgtGetFirstPartInRawPart(nRawPartId)
If nPartId <> GDB_ID.NULL Then
Dim NewBeam As BeamM = BeamM.CreateBeam(NewBeamMachGroupM, nPartId, nRawPartId)
TempList.Add(NewBeam)
NewBeam.UpdateOffset()
End If
nRawPartId = EgtGetNextRawPart(nRawPartId)
End While
Return TempList
End Function
Public Overrides Sub RefreshPartList()
' leggo StartCut da posizione primo pezzo
Dim sInfo As String = ""
Dim sSplitInfo() As String
Dim bFound As Boolean = False
EgtGetInfo(Id, MGR_RPT_PART & 1, sInfo)
If Not String.IsNullOrWhiteSpace(sInfo) Then
sSplitInfo = sInfo.Split(","c)
StringToDouble(sSplitInfo(1), m_dStartCut)
Else
m_dStartCut = 0
End If
' aggiorno lista pezzi
PartMList.Clear()
Dim nRawPartId As Integer = EgtGetFirstRawPart()
While nRawPartId <> GDB_ID.NULL
Dim nPartId As Integer = EgtGetFirstPartInRawPart(nRawPartId)
If nPartId <> GDB_ID.NULL Then
Dim NewBeam As BeamM = BeamM.CreateBeam(Me, nPartId, nRawPartId)
PartMList.Add(NewBeam)
NewBeam.UpdateOffset()
End If
nRawPartId = EgtGetNextRawPart(nRawPartId)
End While
End Sub
Public Overrides Sub RefreshGroupData()
EgtGetInfo(Id, MGR_RPT_BARLEN, dL)
EgtGetInfo(Id, MGR_RPT_BARHEIGHT, dH)
EgtGetInfo(Id, MGR_RPT_BARWIDTH, dW)
End Sub
End Class
@@ -6,7 +6,7 @@ Imports EgtUILib
Imports EgtWPFLib5
Public MustInherit Class MyMachGroupM
Inherits MachGroup
Inherits MachGroupM
Protected m_nMachineType As MachineType
Public ReadOnly Property nMachineType As MachineType
@@ -69,30 +69,24 @@ Public MustInherit Class MyMachGroupM
End Property
Protected m_dMatForPart As Double = 0
Public ReadOnly Property dMatForPart As Double
Get
Return m_dMatForPart
End Get
End Property
Public Sub SetMatForPart(dMatForPart As Double)
m_dMatForPart = dMatForPart
End Sub
Protected m_dTotMat As Double = 0
Public ReadOnly Property dUsage As Double
Public ReadOnly Property dTotMat As Double
Get
Return If(m_dMatForPart > 0 AndAlso m_dTotMat > 0, m_dMatForPart / m_dTotMat * 100, 0)
End Get
End Property
Public ReadOnly Property dWaste As Double
Get
Return If(m_dMatForPart > 0 AndAlso m_dTotMat > 0, (m_dTotMat - m_dMatForPart) / m_dTotMat * 100, 0)
End Get
End Property
Public ReadOnly Property sUsage As String
Get
Return dUsage & "%"
End Get
End Property
Public ReadOnly Property sWaste As String
Get
Return dWaste & "%"
Return m_dTotMat
End Get
End Property
Public Sub SetTotMat(TotMat As Double)
m_dTotMat = TotMat
End Sub
Protected m_sMATERIAL As String
Public Property sMATERIAL As String
@@ -105,28 +99,13 @@ Public MustInherit Class MyMachGroupM
End Property
' lista dei pezzi che sono nel grezzo
Private m_PartList As New ObservableCollection(Of PartM)
Public Property PartList As ObservableCollection(Of PartM)
Protected m_PartMList As New List(Of PartM)
Public Property PartMList As List(Of PartM)
Get
Return m_PartList
Return m_PartMList
End Get
Set(value As ObservableCollection(Of PartM))
m_PartList = value
End Set
End Property
Protected m_SelPart As PartM
Public Overridable Property SelPart As PartM
Get
Return m_SelPart
End Get
Set(value As PartM)
m_SelPart = value
' seleziono pezzo
EgtDeselectAll()
If Not IsNothing(value) Then EgtSelectObj(SelPart.nPartId)
EgtDraw()
NotifyPropertyChanged(NameOf(SelPart))
Set(value As List(Of PartM))
m_PartMList = value
End Set
End Property
@@ -136,27 +115,38 @@ Public MustInherit Class MyMachGroupM
Return m_nState
End Get
End Property
Public ReadOnly Property Calc_Background As SolidColorBrush
Get
If m_nState = 0 Then
Return Brushes.Green
ElseIf m_nState < 0 Then
Return Brushes.LightGray
ElseIf m_nState > 0 Then
Return Brushes.Red
Else
Return Brushes.Red
End If
End Get
End Property
Sub New(nId As Integer, sName As String, sMachine As String)
MyBase.New(nId, sName, sMachine)
'aggiorno lista pezzi
RefreshPartList()
Public Sub SetState(nState As CalcStates)
m_nState = nState
End Sub
#Region "CONSTRUCTOR"
'Sub New(nId As Integer, sName As String, sMachine As String)
' MyBase.New(nId, sName, sMachine)
' 'aggiorno lista pezzi
' RefreshPartList()
'End Sub
#End Region ' CONSTRUCTOR
#Region "METHODS"
Public Event PartAdded As EventHandler(Of PartAddedEventArgs)
Public Sub AddPart(PartM As PartM)
If IsNothing(PartM) Then Return
If Not m_PartMList.Contains(PartM) Then
m_PartMList.Add(PartM)
RaiseEvent PartAdded(Me, New PartAddedEventArgs(PartM))
End If
End Sub
Public Function GetParts() As List(Of PartM)
Return New List(Of PartM)(m_PartMList)
End Function
#End Region ' METHODS
Public MustOverride Sub RefreshPartList()
Public MustOverride Sub RefreshGroupData()
@@ -175,14 +165,4 @@ Public MustInherit Class MyMachGroupM
EgtRemoveMachGroup(Me.Id)
End Sub
Public Sub CalcMachGroupUpdate()
m_nState = CalcStates.OK
For Each Part In PartList
If Part.nGlobalState > 0 AndAlso m_nState = CalcStates.OK Then
m_nState = CalcStates.ERROR_
End If
Next
NotifyPropertyChanged(NameOf(Calc_Background))
End Sub
End Class
@@ -0,0 +1,182 @@
Imports System.Collections.ObjectModel
Imports System.IO
Imports EgtUILib
Imports EgtWPFLib5
Public Class MyMachGroupPanelM
Inherits MachGroupPanelM
#Region "FIELDS & PROPERTIES"
#End Region ' FIELDS & PROPERTIES
#Region "CONSTRUCTOR"
Public Shared Function CreateMyMachGroupPanel(MachineList As List(Of Machine)) As MachGroupPanelM
Dim NewMyMachGroupPanelM As New MyMachGroupPanelM
NewMyMachGroupPanelM.m_IsMultiMachGroup = False
' Assegno nome base
NewMyMachGroupPanelM.m_BaseName = ""
' Recupero lista macchine
NewMyMachGroupPanelM.m_MachineList = MachineList
' Assegno macchina di default
NewMyMachGroupPanelM.m_DefaultMachine = ""
' recupero i MachGroup
NewMyMachGroupPanelM.m_MachGroupMList = LoadMyMachGroups(MachineList)
Return NewMyMachGroupPanelM
End Function
#End Region ' CONSTRUCTOR
#Region "METHODS"
Public Shared Function LoadMyMachGroups(MachineList As List(Of Machine)) As List(Of MachGroupM)
Dim TempList As New List(Of MachGroupM)
' Carico i gruppi di lavorazione nella lista
Dim nId = EgtGetFirstMachGroup()
While nId <> GDB_ID.NULL
EgtSetCurrMachGroup(nId)
Dim sName As String = String.Empty
Dim sMachine As String = String.Empty
EgtGetMachGroupName(nId, sName)
EgtGetMachGroupMachineName(nId, sMachine)
' cerco la macchina tra quelle presenti
Dim UsedMachine As MyMachine = Nothing
Dim bOk As Boolean = Machine.SearchMachine(sMachine, MachineList, UsedMachine)
If Not bOk OrElse UsedMachine.nType = MachineType.NULL Then
EgtOutLog("Machine incompatible with beam & wall machining!!")
ElseIf UsedMachine.nType = MachineType.BEAM Then
TempList.Add(BeamMachGroupM.CreateBeamMachGroup(nId, sName, sMachine))
ElseIf UsedMachine.nType = MachineType.WALL Then
TempList.Add(New WallMachGroup(nId, sName, sMachine))
End If
nId = EgtGetNextMachGroup(nId)
End While
EgtResetCurrMachGroup()
Return TempList
End Function
Public Function NewMyMachGroup(sMachName As String, nMachineType As MachineType) As MachGroupM
' Sistemazioni preliminari
OnPreNewMachGroup()
' Se non ci sono macchine disponibili esco con errore
If m_MachineList.Count <= 0 Then Return Nothing
' Creo il nuovo gruppo di lavorazione con i dati ottenuti a seconda del caso in cui mi trovo
Dim MachGroupM As MachGroupM
If nMachineType = MachineType.NULL Then
EgtOutLog("Machine incompatible with beam & wall machining!!")
Return Nothing
ElseIf nMachineType = MachineType.BEAM Then
MachGroupM = BeamMachGroupM.CreateBeamMachGroup(NewMachGroupID(), sMachName)
ElseIf nMachineType = MachineType.WALL Then
MachGroupM = WallMachGroup.CreateMachGroup(NewMachGroupID(), sMachName)
End If
If IsNothing(MachGroupM) Then Return Nothing
AddMachGroup(MachGroupM)
' Sistemazioni finali
m_DefaultMachine = sMachName
OnPostNewMachGroup()
Return MachGroupM
End Function
Public Overrides Function OnPreNewMachGroup() As Boolean
'EgtSetCurrentContext(Map.refSceneHostVM.MainScene.GetCtx())
Return True
End Function
' NB: Anche se ho già aggiunto il nuovo gruppo di lavorazione, non l'ho ancora reso corrente (viene fatto dopo), quindi
' non posso usare CurrentMachine perchè è ancora impostata quella precedente!!!
Public Overrides Function OnPostNewMachGroup() As Boolean
' Salvo macchina del gruppo come nuovo default
Dim sCurrMachName As String = String.Empty
EgtGetCurrMachineName(sCurrMachName)
WriteMainPrivateProfileString(S_MACH, K_CURRMACH, sCurrMachName)
'' leggo nome attrezzaggio di default
'Dim sDefaultSetUpName As String = String.Empty
'Dim sMachineIniPath As String = Map.refMainWindowVM.MainWindowM.sMachinesRoot & "\" & sCurrMachName & "\" & sCurrMachName & ".ini"
'EgtUILib.GetPrivateProfileString(S_SETUP, K_DEFAULT, "", sDefaultSetUpName, sMachineIniPath)
'' se è attiva l'opzione, rendo corrente l'attrezzaggio di default
'If Not String.IsNullOrEmpty(sDefaultSetUpName) Then
' If Not EgtImportSetup(sDefaultSetUpName) Then
' EgtOutLog("Error loading default setup " & sDefaultSetUpName)
' MessageBox.Show(EgtMsg(MSG_SETUPERRORS + 9) & " " & sDefaultSetUpName, EgtMsg(MSG_MESSAGEBOX + 1), MessageBoxButton.OK, MessageBoxImage.Exclamation)
' End If
'End If
Return True
End Function
Public Overrides Function OnPreRemoveCurrMachGroup() As Boolean
'EgtSetCurrentContext(Map.refSceneHostVM.MainScene.GetCtx())
Return True
End Function
Public Function NewMachGroupID() As Integer
If Not IsNothing(MachGroupMList) AndAlso MachGroupMList.Count > 0 Then Return MachGroupMList.Max(Function(x) x.Name) + 1
Return 1
End Function
' funzione che fa l'update di tutte le copie dei pezzi modificati
Public Sub UpdateDuplo()
Dim nPartId As Integer = EgtGetFirstPart()
While nPartId <> GDB_ID.NULL
Dim bIsModified As Boolean = False
If EgtDuploGetModified(nPartId, bIsModified) AndAlso bIsModified Then
EgtDuploUpdate(nPartId)
End If
nPartId = EgtGetNextPart(nPartId)
End While
End Sub
' funzione che cancella tutti i pezzi segnati da eliminare
Public Sub DeleteDuplo()
Dim nPartId As Integer = EgtGetFirstPart()
While nPartId <> GDB_ID.NULL
Dim bIsToDelete As Boolean = False
If DuploGetToDelete(nPartId, bIsToDelete) AndAlso bIsToDelete Then
' verifico se ci sono copie
Dim nDuploCount As Integer = 0
EgtDuploCount(nPartId, nDuploCount)
Dim DuploList As New List(Of Integer)
If nDuploCount > 0 AndAlso EgtDuploList(nPartId, DuploList) Then
' cancello tutti i pezzi copia nelle barre
For Each nDuploId In DuploList
' reset necessario per poter accedere direttamente al grezzo dalle info pezzo e al MachGroup tramite la gerarchia Db geometrico
EgtResetCurrMachGroup()
' recupero grezzo cui appartiene
Dim nRawPartId As Integer
EgtGetInfo(nDuploId, "!LST", nRawPartId)
' recupero gruppo di lavorazione
Dim nMachGroupId As Integer = EgtGetParent(EgtGetParent(EgtGetParent(nRawPartId)))
' recupero gruppo di lavorazione e trave dell'interfaccia
Dim BeamMachGroup As BeamMachGroupM = MachGroupMList.FirstOrDefault(Function(x) x.Id = nMachGroupId)
Dim Beam As BeamM = BeamMachGroup.PartMList.FirstOrDefault(Function(x) x.nPartId = nDuploId)
EgtSetCurrMachGroup(BeamMachGroup.Id)
'''Beam.DeletePart()
Next
End If
DuploResetToDelete(nPartId)
End If
nPartId = EgtGetNextPart(nPartId)
End While
EgtResetCurrMachGroup()
End Sub
Friend Shared Function DuploGetToDelete(nSouId As Integer, ByRef bToDelete As Boolean) As Boolean
If IsNothing(nSouId) Then Return False
Return EgtGetInfo(nSouId, DUPLO_TODELETE, bToDelete)
End Function
Public Shared Function DuploSetToDelete(nSouId As Integer) As Boolean
If IsNothing(nSouId) Then Return False
Return EgtSetInfo(nSouId, DUPLO_TODELETE, True)
End Function
Private Function DuploResetToDelete(nSouId As Integer) As Boolean
If IsNothing(nSouId) Then Return False
Return EgtSetInfo(nSouId, DUPLO_TODELETE, "")
End Function
#End Region ' METHODS
End Class
+46
View File
@@ -0,0 +1,46 @@
Imports System.IO
Imports EgtWPFLib5
Public Class MyMachine
Inherits Machine
Private m_nType As MachineType
Public ReadOnly Property nType As MachineType
Get
Return m_nType
End Get
End Property
Sub New(sDirPath As String, sIniPath As String)
MyBase.New(sDirPath, sIniPath)
' verifico esistenza cartella beam per assegnare tipo
If Directory.Exists(sDirPath & "/Beam") Then
m_nType = MachineType.BEAM
ElseIf Directory.Exists(sDirPath & "/Wall") Then
m_nType = MachineType.WALL
Else
m_nType = MachineType.NULL
End If
End Sub
Public Shared Shadows Function MachineListInit(sMachinesRootDir As String, MachineList As IList(Of Machine)) As Boolean
' Se direttorio base macchine non definito o non esiste, ritorno
If String.IsNullOrWhiteSpace(sMachinesRootDir) OrElse
Not Directory.Exists(sMachinesRootDir) Then
MachineList = Nothing
Return False
End If
' Cerco le macchine
Dim Machines As String() = Directory.GetDirectories(sMachinesRootDir)
For i As Integer = 0 To Machines.Count - 1
Dim PathIni As String = Machines(i) & "\" & Path.GetFileName(Machines(i)) & ".ini"
Dim PathBeam As String = Machines(i) & "\" & "Beam"
Dim PathWall As String = Machines(i) & "\" & "Wall"
If File.Exists(PathIni) AndAlso (Directory.Exists(PathBeam) OrElse Directory.Exists(PathWall)) Then
MachineList.Add(New MyMachine(Machines(i), PathIni))
End If
Next
Return True
End Function
End Class
+42 -117
View File
@@ -85,21 +85,12 @@ Public MustInherit Class PartM
End Property
Protected m_dPOSX As Double
Public Property sPOSX As String
Get
Return LenToString(m_dPOSX, 3)
End Get
Set(value As String)
StringToLen(value, m_dPOSX)
End Set
End Property
Public Property dPOSX As Double
Get
Return m_dPOSX
End Get
Set(value As Double)
m_dPOSX = value
NotifyPropertyChanged(NameOf(sPOSX))
End Set
End Property
@@ -114,9 +105,9 @@ Public MustInherit Class PartM
End Property
Protected m_nINVERTED As Integer
Public ReadOnly Property sINVERTED As String
Public ReadOnly Property nINVERTED As Integer
Get
Return m_nINVERTED & "°"
Return m_nINVERTED
End Get
End Property
Public Sub SetInverted(nInverted As Integer)
@@ -124,9 +115,9 @@ Public MustInherit Class PartM
End Sub
Protected m_nROTATED As Integer
Public ReadOnly Property sROTATED As String
Public ReadOnly Property nROTATED As Integer
Get
Return m_nROTATED & "°"
Return m_nROTATED
End Get
End Property
Public Sub SetRotated(nRotated As Integer)
@@ -144,10 +135,13 @@ Public MustInherit Class PartM
End Property
Protected m_nGlobalState As CalcStates = -1
Public ReadOnly Property nGlobalState As CalcStates
Public Property nGlobalState As CalcStates
Get
Return m_nGlobalState
End Get
Set(value As CalcStates)
m_nGlobalState = value
End Set
End Property
Protected m_nState As CalcStates = -1
@@ -160,32 +154,24 @@ Public MustInherit Class PartM
End Set
End Property
Public ReadOnly Property Calc_Background As SolidColorBrush
Get
If m_nGlobalState = 0 Then
Return Brushes.Green
ElseIf m_nGlobalState < 0 Then
Return Brushes.LightGray
ElseIf m_nGlobalState > 0 Then
Return Brushes.Red
Else
Return Brushes.Red
End If
End Get
End Property
Protected m_nCALC_ERR As Integer
Public ReadOnly Property nCALC_ERR As Integer
Public Property nCALC_ERR As Integer
Get
Return m_nCALC_ERR
End Get
Set(value As Integer)
m_nCALC_ERR = value
End Set
End Property
Protected m_sCALC_MSG As String = String.Empty
Public ReadOnly Property nCALC_MSG As String
Public Property sCALC_MSG As String
Get
Return m_sCALC_MSG
End Get
Set(value As String)
m_sCALC_MSG = value
End Set
End Property
Protected m_nCALC_ROT As Integer
@@ -219,29 +205,16 @@ Public MustInherit Class PartM
End Property
' lista delle feature del pezzo
Protected m_FeatureList As ObservableCollection(Of BTLFeatureM)
Public Property FeatureList As ObservableCollection(Of BTLFeatureM)
Protected m_FeatureMList As ObservableCollection(Of BTLFeatureM)
Public Property FeatureMList As ObservableCollection(Of BTLFeatureM)
Get
Return m_FeatureList
Return m_FeatureMList
End Get
Set(value As ObservableCollection(Of BTLFeatureM))
m_FeatureList = value
m_FeatureMList = value
End Set
End Property
Protected m_SelFeature As BTLFeatureM
Public Property SelFeature As BTLFeatureM
Get
Return m_SelFeature
End Get
Set(value As BTLFeatureM)
m_SelFeature = value
EgtDeselectAll()
If Not IsNothing(value) Then EgtSelectObj(m_SelFeature.nFeatureId)
EgtDraw()
NotifyPropertyChanged(NameOf(SelFeature))
End Set
End Property
Protected m_dtStartTime As DateTime
Public Property dtStartTime As DateTime
@@ -263,9 +236,6 @@ Public MustInherit Class PartM
End Set
End Property
' definizione comandi
Private m_cmdDeletePart As ICommand
#End Region ' FIELDS & PROPERTIES
#Region "CONSTRUCTOR"
@@ -273,11 +243,29 @@ Public MustInherit Class PartM
Sub New(nParentMachGroup As MyMachGroupM, nPartId As Integer)
m_ParentMachGroup = nParentMachGroup
SetPartId(nPartId)
m_FeatureList = New ObservableCollection(Of BTLFeatureM)
m_FeatureMList = New ObservableCollection(Of BTLFeatureM)
End Sub
#End Region ' CONSTRUCTOR
#Region "METHODS"
Public Event BTLFeatureAdded As EventHandler(Of BTLFeatureAddedEventArgs)
Public Sub AddBTLFeature(BTLFeatureM As BTLFeatureM)
If IsNothing(BTLFeatureM) Then Return
If Not m_FeatureMList.Contains(BTLFeatureM) Then
m_FeatureMList.Add(BTLFeatureM)
RaiseEvent BTLFeatureAdded(Me, New BTLFeatureAddedEventArgs(BTLFeatureM))
End If
End Sub
Public Function GetBTLFeatures() As List(Of BTLFeatureM)
Return New List(Of BTLFeatureM)(m_FeatureMList)
End Function
#End Region ' METHODS
' funzione che aggiorna lo stato e gli errori dopo calcolo
Public Sub CalcPartUpdate(bCalc As Boolean, ERR As Integer, ROT As Integer, FALL As Integer, MSG As String)
If Not bCalc Then
@@ -299,13 +287,13 @@ Public MustInherit Class PartM
nState = CalcStates.NOTCALCULATED
End If
End If
NotifyPropertyChanged(NameOf(Calc_Background))
'''NotifyPropertyChanged(NameOf(Calc_Background))
End Sub
' funzione che aggiorna lo stato e gli errori dopo calcolo
Public Sub CalcFeatureUpdate()
m_nGlobalState = nState
For Each Feature In FeatureList
For Each Feature In FeatureMList
If Not Feature.bDO Then
ElseIf Feature.nState < 0 Then
@@ -315,70 +303,7 @@ Public MustInherit Class PartM
m_nGlobalState = CalcStates.ERROR_
End If
Next
NotifyPropertyChanged(NameOf(Calc_Background))
'''NotifyPropertyChanged(NameOf(Calc_Background))
End Sub
#Region "COMMANDS"
#Region "DeletePart"
' Returns a command that manage the MainWindow_Unloaded command
Public ReadOnly Property DeletePart_Command() As ICommand
Get
If m_cmdDeletePart Is Nothing Then
m_cmdDeletePart = New Command(AddressOf DeletePart)
End If
Return m_cmdDeletePart
End Get
End Property
' Manage the MainWindow_Unloaded event. This method is invoked by the cmdMainWindow_Unloaded.
Public Overridable Sub DeletePart()
EgtRemovePartFromRawPart(Me.m_nPartId)
' elimino pezzo copia
EgtErase(Me.m_nPartId)
' elimino info pezzo su mach group
Dim sInfo As String = ""
Dim Index As Integer = 1
Dim sSplitInfo() As String
Dim bFound As Boolean = False
While EgtGetInfo(m_ParentMachGroup.Id, MGR_RPT_PART & Index, sInfo)
If Not String.IsNullOrWhiteSpace(sInfo) Then
sSplitInfo = sInfo.Split(","c)
If bFound Then
EgtSetInfo(m_ParentMachGroup.Id, MGR_RPT_PART & Index - 1, sInfo)
End If
If sSplitInfo(0) = nPartId Then
bFound = True
End If
End If
Index += 1
End While
If bFound Then
EgtSetInfo(m_ParentMachGroup.Id, MGR_RPT_PART & Index - 1, "")
End If
' rimuovo dalla lista pezzi
Index = ParentMachGroup.PartList.IndexOf(Me)
If Index = 0 Then
If ParentMachGroup.PartList.Count > 0 Then
ParentMachGroup.SelPart = ParentMachGroup.PartList(0)
Else
ParentMachGroup.SelPart = Nothing
End If
ElseIf Index = ParentMachGroup.PartList.Count - 1 Then
If ParentMachGroup.PartList.Count > 1 Then
ParentMachGroup.SelPart = ParentMachGroup.PartList(ParentMachGroup.PartList.Count - 2)
Else
ParentMachGroup.SelPart = Nothing
End If
Else
ParentMachGroup.SelPart = ParentMachGroup.PartList(Index - 1)
End If
ParentMachGroup.PartList.Remove(Me)
End Sub
#End Region ' DeletePart
#End Region ' COMMANDS
End Class
+4 -4
View File
@@ -14,24 +14,24 @@ Public Class WallMachGroup
End Property
Sub New(nId As Integer, sName As String, sMachine As String)
MyBase.New(nId, sName, sMachine)
'''MyBase.New(nId, sName, sMachine)
SetMachineType(MachineType.WALL)
m_nRawPartId = EgtGetFirstRawPart()
EgtGetInfo(nId, MGR_RPT_PANELLEN, dL)
EgtGetInfo(nId, MGR_RPT_PANELWIDTH, dW)
EgtGetInfo(nId, MGR_RPT_PANELHEIGHT, dH)
m_dTotMat = dL * dW
For Each Part In PartList
For Each Part In PartMList
m_dMatForPart += (Part.dL * Part.dW)
Next
End Sub
Public Overrides Sub RefreshPartList()
m_nRawPartId = EgtGetFirstRawPart()
PartList.Clear()
PartMList.Clear()
Dim nPartId As Integer = EgtGetFirstPartInRawPart(m_nRawPartId)
While nPartId <> GDB_ID.NULL
PartList.Add(New Wall(Me, nPartId))
PartMList.Add(New Wall(Me, nPartId))
nPartId = EgtGetNextPartInRawPart(nPartId)
End While
End Sub