diff --git a/Constants/ConstMachIni.vb b/Constants/ConstMachIni.vb index 1ef8ad4..70bb417 100644 --- a/Constants/ConstMachIni.vb +++ b/Constants/ConstMachIni.vb @@ -58,5 +58,6 @@ Public Const K_VM_ENABLE As String = "Enable" Public Const S_ESTIMATIONS As String = "Estimations" + Public Const K_EST_ENABLE As String = "Enable" End Module diff --git a/MachGroupPanel/MachGroupPanelVM.vb b/MachGroupPanel/MachGroupPanelVM.vb index 276d5f5..f7bb2ae 100644 --- a/MachGroupPanel/MachGroupPanelVM.vb +++ b/MachGroupPanel/MachGroupPanelVM.vb @@ -337,6 +337,8 @@ Public Class MachGroupPanelVM EgtZoom(ZM.ALL) Application.Msn.NotifyColleagues(Application.LOADOPERATIONLIST, -1) Application.Msn.NotifyColleagues(Application.UPDATECURRENTMACHINE) + Map.refSimulationExpanderVM.Estimation_IsEnabled = + (EgtUILib.GetPrivateProfileInt(S_ESTIMATIONS, K_EST_ENABLE, 0, IniFile.m_sCurrMachIniFilePath) <> 0) End Sub #End Region ' SetCurrMachGroupCommand diff --git a/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderV.xaml.vb b/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderV.xaml.vb index e2a4deb..638eae1 100644 --- a/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderV.xaml.vb +++ b/OptionPanel/MachiningOptionPanel/OperationExpander/OperationExpanderV.xaml.vb @@ -30,7 +30,7 @@ Public Class OperationExpanderV SimulationUserControl = DirectCast(SimulationContentPresenter.Content, UserControl) SimulationExpanderStackPanel = DirectCast(SimulationUserControl.Content, StackPanel) SimulationExpander = DirectCast(SimulationExpanderStackPanel.Children(0), Expander) - GenerateButton = DirectCast(SimulationExpanderStackPanel.Children(1), Button) + GenerateButton = DirectCast(SimulationExpanderStackPanel.Children(2), Button) ' Gestisco l'evento SizeChanged della Tray AddHandler EgtFloatingTray.SizeChanged, AddressOf OperationExpanderTray_SizeChanged m_bFirst = False diff --git a/OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderView.xaml b/OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderView.xaml index 06aed4e..8c17ba7 100644 --- a/OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderView.xaml +++ b/OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderView.xaml @@ -103,6 +103,7 @@ diff --git a/OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderViewModel.vb b/OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderViewModel.vb index 398c483..b6cad02 100644 --- a/OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderViewModel.vb +++ b/OptionPanel/MachiningOptionPanel/SimulationExpander/SimulationExpanderViewModel.vb @@ -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. ''' 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 \ No newline at end of file diff --git a/OptionPanel/OptionPanelVM.vb b/OptionPanel/OptionPanelVM.vb index 55d2764..4f95a7c 100644 --- a/OptionPanel/OptionPanelVM.vb +++ b/OptionPanel/OptionPanelVM.vb @@ -64,6 +64,8 @@ Public Class OptionPanelVM m_SimulationExpander = New SimulationExpanderV m_SimulationExpander.DataContext = New SimulationExpanderVM End If + Map.refSimulationExpanderVM.Estimation_IsEnabled = + (EgtUILib.GetPrivateProfileInt(S_ESTIMATIONS, K_EST_ENABLE, 0, IniFile.m_sCurrMachIniFilePath) <> 0) Return m_SimulationExpander End If End Get diff --git a/Utility/Map.vb b/Utility/Map.vb index fbf5e6d..3465447 100644 --- a/Utility/Map.vb +++ b/Utility/Map.vb @@ -7,6 +7,7 @@ Private m_refTopCommandBarVM As TopCommandBarVM Private m_refProjectVM As ProjectVM Private m_refFixtureParametersVM As FixtureParametersVM + Private m_refSimulationExpanderVM As SimulationExpanderVM #Region "Get" @@ -35,6 +36,11 @@ Return m_refFixtureParametersVM End Get End Property + Public ReadOnly Property refSimulationExpanderVM As SimulationExpanderVM + Get + Return m_refSimulationExpanderVM + End Get + End Property #End Region ' Get @@ -56,6 +62,10 @@ m_refFixtureParametersVM = FixtureParametersVM Return Not IsNothing(m_refFixtureParametersVM) End Function + Friend Function SetRefSimulationExpanderVM(SimulationExpanderVM As SimulationExpanderVM) As Boolean + m_refSimulationExpanderVM = SimulationExpanderVM + Return Not IsNothing(m_refSimulationExpanderVM) + End Function #End Region ' Set @@ -68,7 +78,7 @@ Friend Function EndInit() As Boolean ' Verifico se tutti i pezzi necessari sono stati caricati Return Not IsNothing(m_refMainWindowVM) AndAlso Not IsNothing(m_refStatusBarVM) AndAlso Not IsNothing(m_refProjectVM) AndAlso Not IsNothing(m_refTopCommandBarVM) AndAlso - Not IsNothing(m_refFixtureParametersVM) + Not IsNothing(m_refFixtureParametersVM) AndAlso Not IsNothing(m_refSimulationExpanderVM) End Function #End Region ' Init