EgtCAM5 :

- sistemazioni per stime.
This commit is contained in:
Dario Sassi
2018-06-06 11:20:54 +00:00
parent c4a9533a17
commit fe8de80259
7 changed files with 122 additions and 3 deletions
@@ -96,6 +96,7 @@ Public Class SimulationExpanderVM
EgtDeselectAll()
Application.Msn.NotifyColleagues(Application.REMOVEMARKFROMLASTOPERATION)
Application.Msn.NotifyColleagues(Application.GETDISTANCE_ISCHECKED, False)
CalcEstimation()
OnPropertyChanged("TotalTime")
OnPropertyChanged("TotalLength")
IsExpanded = False
@@ -108,6 +109,17 @@ Public Class SimulationExpanderVM
End Set
End Property
Private m_Estimation_IsEnabled As Boolean = False
Public Property Estimation_IsEnabled As Boolean
Get
Return m_Estimation_IsEnabled
End Get
Set(value As Boolean)
m_Estimation_IsEnabled = value
OnPropertyChanged("Estimation_IsEnabled")
End Set
End Property
Public ReadOnly Property GenerateIsEnabled As Boolean
Get
Return Not m_IsExpanded
@@ -366,6 +378,7 @@ Public Class SimulationExpanderVM
#Region "CONSTRUCTOR"
Sub New()
SetRefSimulationExpanderVM(Me)
Application.Msn.Register(Application.CLOSEAPPLICATION, Sub()
If IsExpanded Then
ResetSimulation()
@@ -608,7 +621,18 @@ Public Class SimulationExpanderVM
''' Creata the new tool. This method is invoked by the NewCommand.
''' </summary>
Public Sub Details(ByVal param As Object)
Dim EstimationsWnd As New EstimationsDetailsWndV(Application.Current.MainWindow, New EstimationsDetailsWndVM("c:\Temp\0088_Mach01.html"))
' Determino il nome del file contenente le stime
Dim sEstFile As String = ""
Dim sInfo As String = ""
GetEstimationFileName(False, sEstFile, sInfo)
' Verifico che il file esista
If Not File.Exists(sEstFile) Then
' File delle stime non trovato
MessageBox.Show(EgtMsg(MSG_SIMULATION + 18), EgtMsg(MSG_SIMULATION + 15), MessageBoxButton.OK, MessageBoxImage.Warning)
Return
End If
' Visualizzazione
Dim EstimationsWnd As New EstimationsDetailsWndV(Application.Current.MainWindow, New EstimationsDetailsWndVM(sEstFile))
EstimationsWnd.ShowDialog()
End Sub
@@ -863,6 +887,85 @@ Public Class SimulationExpanderVM
End If
End Sub
Private Function GetEstimationFileName(bAskSave As Boolean, ByRef sEstFile As String, ByRef sInfo As String) As Boolean
Dim bOk As Boolean = True
' Recupero e verifico la path del progetto corrente
Dim sCurrFilePath As String = String.Empty
EgtGetCurrFilePath(sCurrFilePath)
If bAskSave Then
If String.IsNullOrEmpty(sCurrFilePath) OrElse EgtGetModified() Then
' Il progetto deve essere salvato prima di poter essere generato. Vuoi farlo ?
If MessageBox.Show(EgtMsg(MSG_SIMULATION + 31), EgtMsg(MSG_SIMULATION + 15), MessageBoxButton.YesNo, MessageBoxImage.Warning) = MessageBoxResult.No Then
' Abbandono
bOk = False
Else
' Lancio salvataggio
Application.Msn.NotifyColleagues(Application.SAVEPROJECT)
EgtGetCurrFilePath(sCurrFilePath)
' Se non salvato, abbandono
If EgtGetModified() Then bOk = False
End If
End If
Else
If String.IsNullOrEmpty(sCurrFilePath) Then
' File delle stime non trovato
MessageBox.Show(EgtMsg(MSG_SIMULATION + 18), EgtMsg(MSG_SIMULATION + 15), MessageBoxButton.OK, MessageBoxImage.Warning)
bOk = False
End If
End If
' Creo la path del file di stima e relativo info (con nome gruppo se gestiti)
If Not String.IsNullOrEmpty(sCurrFilePath) Then
sEstFile = Path.ChangeExtension(sCurrFilePath, Nothing)
sInfo = "EgtCAM5 - " & sCurrFilePath
If IniFile.m_bMachiningGroup Then
Dim sMGrpName As String = String.Empty
If EgtGetMachGroupName(EgtGetCurrMachGroup(), sMGrpName) Then
sEstFile &= "_" & sMGrpName & ".html"
sInfo &= "-" & sMGrpName
End If
Else
sEstFile &= ".html"
End If
End If
Return bOk
End Function
Private Function CalcEstimation() As Boolean
' Recupero la fase corrente
Dim nPhase As Integer = EgtGetCurrPhase()
' Aggiorno le lavorazioni
If Not UpdateAllMachinings() Then
EgtSetCurrPhase(If(nPhase = 0, 1, nPhase), True)
Return False
End If
' Determino il nome del file contenente le stime
Dim sEstFile As String = ""
Dim sInfo As String = ""
Dim bOk As Boolean = GetEstimationFileName(True, sEstFile, sInfo)
' Cancello tutte le stime
If File.Exists(sEstFile) Then File.Delete(sEstFile)
Dim bOldEnMod As Boolean = EgtGetEnableModified()
EgtDisableModified()
EgtRemoveInfo(EgtGetCurrMachGroup(), "Ttot")
EgtRemoveInfo(EgtGetCurrMachGroup(), "Ltot")
If bOldEnMod Then EgtEnableModified()
If Not bOk Then Return False
' Calcolo della stima
If Not EgtEstimate(sEstFile, sInfo) Then
If EgtGetLastMachMgrErrorId() <> 0 Then
Dim sErr As String = EgtGetLastMachMgrErrorString()
sErr = sErr.Replace("Cnc", "Est")
MessageBox.Show(sErr, EgtMsg(MSG_SIMULATION + 5), MessageBoxButton.OK, MessageBoxImage.Exclamation)
Else
MessageBox.Show(EgtMsg(MSG_SIMULATION + 17), EgtMsg(MSG_SIMULATION + 5), MessageBoxButton.OK, MessageBoxImage.Error)
End If
bOk = False
End If
' Torno alla fase originale (o alla prima se non definita)
EgtSetCurrPhase(If(nPhase = 0, 1, nPhase), True)
Return bOk
End Function
#End Region
End Class