- introdotta simulazione
- migliorato SliceManager - introdotto calcolo tempo e massa materiale
This commit is contained in:
@@ -0,0 +1,358 @@
|
||||
Imports System.Collections.ObjectModel
|
||||
Imports System.IO
|
||||
Imports EgtUILib
|
||||
Imports EgtWPFLib5
|
||||
|
||||
Public Class SimulationPanelVM
|
||||
Inherits VMBase
|
||||
|
||||
#Region "FIELDS & PROPERTIES"
|
||||
|
||||
Public Enum MachViews As Integer
|
||||
TOOL = 0
|
||||
HEAD = 1
|
||||
MACHINE = 2
|
||||
End Enum
|
||||
|
||||
Private m_dPrevAngVertDegView As Double
|
||||
Private m_dPrevAngHorizDegView As Double
|
||||
|
||||
Private m_MySimul As MySimulation
|
||||
Public Property MySimul As MySimulation
|
||||
Get
|
||||
Return m_MySimul
|
||||
End Get
|
||||
Set(value As MySimulation)
|
||||
m_MySimul = value
|
||||
NotifyPropertyChanged("MySimul")
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_MachViewList As New List(Of String)({"Tool", "Head", "Machine"})
|
||||
Public ReadOnly Property MachViewList As List(Of String)
|
||||
Get
|
||||
Return m_MachViewList
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private m_nSelMachView As MachViews
|
||||
Public Property nSelMachView As Integer
|
||||
Get
|
||||
Return m_nSelMachView
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
m_nSelMachView = value
|
||||
Select Case m_nSelMachView
|
||||
Case MachViews.TOOL
|
||||
ToolMode()
|
||||
Case MachViews.HEAD
|
||||
HeadMode()
|
||||
Case MachViews.MACHINE
|
||||
MachMode()
|
||||
End Select
|
||||
End Set
|
||||
End Property
|
||||
Friend Sub SetSelMachView(value As MachViews)
|
||||
nSelMachView = value
|
||||
NotifyPropertyChanged(NameOf(nSelMachView))
|
||||
End Sub
|
||||
|
||||
' Definizione comandi
|
||||
Private m_cmdOk As ICommand
|
||||
Private m_cmdToolMode As ICommand
|
||||
Private m_cmdHeadMode As ICommand
|
||||
Private m_cmdMachMode As ICommand
|
||||
|
||||
#Region "Messages"
|
||||
|
||||
Public ReadOnly Property MachViewMsg As String
|
||||
Get
|
||||
Return "View"
|
||||
End Get
|
||||
End Property
|
||||
|
||||
#End Region ' Messages
|
||||
|
||||
#Region "ToolTip"
|
||||
|
||||
Public ReadOnly Property OneStepToolTip As String
|
||||
Get
|
||||
Return EgtMsg(MSG_SIMULATION + 8)
|
||||
End Get
|
||||
End Property
|
||||
Public ReadOnly Property PlayPauseToolTip As String
|
||||
Get
|
||||
Return EgtMsg(MSG_SIMULATION + 9)
|
||||
End Get
|
||||
End Property
|
||||
Public ReadOnly Property StopHomeToolTip As String
|
||||
Get
|
||||
Return EgtMsg(MSG_SIMULATION + 10)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
#End Region ' ToolTip
|
||||
|
||||
#End Region ' FIELDS & PROPERTIES
|
||||
|
||||
#Region "CONSTRUCTOR"
|
||||
|
||||
Sub New()
|
||||
' Creo riferimento a questa classe in OmagOFFICEMap
|
||||
Map.SetRefSimulationPanelVM(Me)
|
||||
MySimul = New MySimulation
|
||||
' leggo vista macchina da ini e la imposto
|
||||
SetSelMachView(MachViews.MACHINE)
|
||||
End Sub
|
||||
|
||||
#End Region ' CONSTRUCTOR
|
||||
|
||||
#Region "METHODS"
|
||||
|
||||
Friend Sub Refresh(PrevMeasureUnit As MeasureUnitOpt)
|
||||
|
||||
End Sub
|
||||
|
||||
Friend Sub InitSimulation()
|
||||
|
||||
|
||||
'EgtSetCurrentContext(Map.refSceneHostVM.MainScene.GetCtx())
|
||||
' Disabilito Machine Panel (utensili, lavoraz...)
|
||||
'OmagOFFICEMap.refMachinePanelVM.MachPanel_IsEnabled = False
|
||||
' Deseleziono pezzi
|
||||
EgtDeselectAll()
|
||||
' L'attrezzaggio utensili è verificato all'avvio simulazione (con attrezzaggio salvato)
|
||||
' Costringo ad aggiornare UI
|
||||
UpdateUI()
|
||||
'' Se non c'è ordine delle lavorazioni, ne faccio uno automatico
|
||||
'Dim bOk As Boolean = True
|
||||
'If Not EstCalc.GetOrderMachiningFlag() Then
|
||||
' ResetAllMachinings()
|
||||
' bOk = SortAllMachinings()
|
||||
' If bOk Then EstCalc.SetOrderMachiningFlag()
|
||||
' Dim bModif As Boolean = TestAllMachiningsForStrict()
|
||||
' If bModif Then
|
||||
' ' Ridotte alcune lavorazioni per evitare interferenze
|
||||
' OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(90321), 3, MSG_TYPE.WARNING)
|
||||
' Else
|
||||
' ' Aggiornate tutte le lavorazioni
|
||||
' OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(90399), 3, MSG_TYPE.INFO)
|
||||
' End If
|
||||
'End If
|
||||
'' Costringo ad aggiornare UI
|
||||
'UpdateUI()
|
||||
' Disabilito impostazione modificato
|
||||
EgtDisableModified()
|
||||
'' Aggiorno le lavorazioni
|
||||
'bOk = UpdateAllMachiningsToolpaths() And bOk
|
||||
'' Se errore in generazione, segnalo l'errore
|
||||
'If Not bOk Then
|
||||
' ' Errore nella generazione del programma CN
|
||||
' OmagOFFICEMap.refStatusBarVM.SetOutputMessage(EgtMsg(90314), MSG_TYPE.ERROR_)
|
||||
'End If
|
||||
'' Eseguo la stima di tempi, lunghezze ...
|
||||
'Dim bEstim As Boolean = (GetPrivateProfileInt(S_MACH_ESTIMATIONS, K_ENABLEEST, 0, CurrentMachine.sMachIniFile) <> 0)
|
||||
'If bEstim Then
|
||||
' MyEstim.Estimation_IsEnabled = True
|
||||
' EgtSetCurrPhase(1)
|
||||
' EgtEstimate(OmagOFFICEMap.refMainWindowVM.MainWindowM.sTempDir & "\MachProj.html", "OmagCut ver." & OmagOFFICEMap.refMainWindowVM.MainWindowM.sVersion)
|
||||
'Else
|
||||
' MyEstim.Estimation_IsEnabled = False
|
||||
'End If
|
||||
'' Impostazioni box stime
|
||||
'NotifyPropertyChanged("Time")
|
||||
'NotifyPropertyChanged("CutLen")
|
||||
'NotifyPropertyChanged("NetArea")
|
||||
'NotifyPropertyChanged("Usage")
|
||||
'' Nascondo eventuali pezzi in parcheggio
|
||||
'HideParkedParts()
|
||||
'' Nascondo eventuale contorno da foto
|
||||
'EstPhoto.ShowContour(False)
|
||||
' Imposto prima fase
|
||||
EgtSetCurrPhase(1)
|
||||
'ShowAllCurrPhaseMachinings()
|
||||
' Costringo ad aggiornare UI
|
||||
UpdateUI()
|
||||
'Cambio la vista della scena
|
||||
EgtGetGenericView(m_dPrevAngVertDegView, m_dPrevAngHorizDegView)
|
||||
EgtSetView(VT.ISO_SE, False)
|
||||
MySimul.SetMachLook(MCH_LOOK.ALL)
|
||||
EgtSetMachineLook(MySimul.GetMachLook())
|
||||
EgtZoom(ZM.ALL)
|
||||
' Avvio ambiente di simulazione
|
||||
If Not EgtSimInit() OrElse Not EgtSimStart() Then
|
||||
If EgtGetLastMachMgrErrorId() <> 0 Then
|
||||
Dim sErr As String = EgtGetLastMachMgrErrorString()
|
||||
MessageBox.Show(sErr, EgtMsg(MSG_SIMULATION + 5), MessageBoxButton.OK, MessageBoxImage.Exclamation)
|
||||
Else
|
||||
MessageBox.Show(EgtMsg(MSG_MESSAGEBOX + 10), EgtMsg(MSG_SIMULATION + 5), MessageBoxButton.OK, MessageBoxImage.Error)
|
||||
End If
|
||||
End If
|
||||
' Imposto stato corrente
|
||||
MySimul.SetSimulationStatus(MCH_SIM_ST.UI_STOP)
|
||||
MySimul.SetShowPlay(True)
|
||||
MySimul.SetSliderX(GetMainPrivateProfileDouble(S_SIMUL, K_SLIDERX, 1))
|
||||
Dim SliderVal As Double = GetMainPrivateProfileDouble(S_SIMUL, K_SLIDERVAL, 10)
|
||||
MySimul.SliderValue = SliderVal
|
||||
' Carico utensili specializzato
|
||||
' LoadCurrTools()
|
||||
EgtDraw()
|
||||
MySimul.ShowCncData()
|
||||
MySimul.StatusMsg = EgtMsg(MSG_SIMULATIONPAGEUC + 14) ' Home
|
||||
End Sub
|
||||
|
||||
Private Function LoadCurrTools() As Boolean
|
||||
'' Se macchina con cambio utensile non devo fare alcunché
|
||||
'If CurrentMachine.MountedToolConfig = CurrentMachine.MountedToolConfigs.TOOLCHANGER Then
|
||||
' Return True
|
||||
'End If
|
||||
'' Imposto la lama corrente
|
||||
'Dim sSaw As String = CurrentMachine.sCurrSaw
|
||||
'If Not EgtLoadTool("H1", 1, sSaw) Then
|
||||
' Return False
|
||||
'End If
|
||||
'' Imposto eventuale secondo utensile montato
|
||||
'If CurrentMachine.MountedToolConfig = CurrentMachine.MountedToolConfigs.SAWANDAUXTOOL Then
|
||||
' Dim sTool As String = CurrentMachine.sCurrDrill
|
||||
' If String.IsNullOrEmpty(sTool) Then sTool = CurrentMachine.sCurrMill
|
||||
' If Not String.IsNullOrEmpty(sTool) AndAlso Not EgtLoadTool("H1", 2, sTool) Then
|
||||
' Return False
|
||||
' End If
|
||||
'End If
|
||||
'Return True
|
||||
End Function
|
||||
|
||||
Friend Sub ExitSimulation()
|
||||
Map.refMyStatusBarVM.ClearOutputMessage()
|
||||
' Mi assicuro di terminare la simulazione
|
||||
MySimul.ResetSimulation()
|
||||
' Ripristino visibilità standard
|
||||
MySimul.SetMachLook(MCH_LOOK.TAB)
|
||||
EgtSetMachineLook(MySimul.GetMachLook())
|
||||
'' Nascondo tutte le lavorazioni
|
||||
'CamAuto.HideAllMachinings()
|
||||
' Abilito impostazione modificato
|
||||
EgtEnableModified()
|
||||
' Cambio la vista della scena
|
||||
EgtSetGenericView(m_dPrevAngVertDegView, m_dPrevAngHorizDegView, False)
|
||||
EgtZoom(ZM.ALL)
|
||||
'' Riabilito Machine Panel (utensili, lavoraz...)
|
||||
'OmagOFFICEMap.refMachinePanelVM.MachPanel_IsEnabled = True
|
||||
End Sub
|
||||
|
||||
#End Region ' METHODS
|
||||
|
||||
#Region "COMMANDS"
|
||||
|
||||
#Region "Ok"
|
||||
|
||||
Public ReadOnly Property Ok_Command As ICommand
|
||||
Get
|
||||
If m_cmdOk Is Nothing Then
|
||||
m_cmdOk = New Command(AddressOf Ok)
|
||||
End If
|
||||
Return m_cmdOk
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Public Sub Ok()
|
||||
' reset gruppo
|
||||
EgtResetCurrMachGroup()
|
||||
' eseguo script di uscita da gruppo corrente
|
||||
Map.refSliceManagerVM.ExecExitMachScript()
|
||||
' ripristino modalita' standard
|
||||
Map.refTopPanelVM.SelPage = Pages.SLICE
|
||||
End Sub
|
||||
|
||||
#End Region ' Ok
|
||||
|
||||
#Region "ToolModeCommand"
|
||||
|
||||
''' <summary>
|
||||
''' Returns a command that create a new tool.
|
||||
''' </summary>
|
||||
Public ReadOnly Property ToolModeCommand As ICommand
|
||||
Get
|
||||
If m_cmdToolMode Is Nothing Then
|
||||
m_cmdToolMode = New Command(AddressOf ToolMode)
|
||||
End If
|
||||
Return m_cmdToolMode
|
||||
End Get
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' Creata the new tool. This method is invoked by the NewCommand.
|
||||
''' </summary>
|
||||
Public Sub ToolMode()
|
||||
' aggiorno lo stato
|
||||
If MySimul.GetMachLook() <> MCH_LOOK.TAB_TOOL Then
|
||||
MySimul.SetMachLook(MCH_LOOK.TAB_TOOL)
|
||||
End If
|
||||
' aggiorno lo stato della macchina e la sua visualizzazione
|
||||
EgtSetMachineLook(MySimul.GetMachLook())
|
||||
EgtDraw()
|
||||
End Sub
|
||||
|
||||
#End Region ' ToolModeCommand
|
||||
|
||||
#Region "HeadModeCommand"
|
||||
|
||||
''' <summary>
|
||||
''' Returns a command that create a new tool.
|
||||
''' </summary>
|
||||
Public ReadOnly Property HeadModeCommand As ICommand
|
||||
Get
|
||||
If m_cmdHeadMode Is Nothing Then
|
||||
m_cmdHeadMode = New Command(AddressOf HeadMode)
|
||||
End If
|
||||
Return m_cmdHeadMode
|
||||
End Get
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' Creata the new tool. This method is invoked by the NewCommand.
|
||||
''' </summary>
|
||||
Public Sub HeadMode()
|
||||
' aggiorno lo stato
|
||||
If MySimul.GetMachLook() <> MCH_LOOK.TAB_HEAD Then
|
||||
MySimul.SetMachLook(MCH_LOOK.TAB_HEAD)
|
||||
End If
|
||||
' aggiorno lo stato della macchina e la sua visualizzazione
|
||||
EgtSetMachineLook(MySimul.GetMachLook())
|
||||
EgtDraw()
|
||||
End Sub
|
||||
|
||||
#End Region ' HeadModeCommand
|
||||
|
||||
#Region "MachModeCommand"
|
||||
|
||||
''' <summary>
|
||||
''' Returns a command that create a new tool.
|
||||
''' </summary>
|
||||
Public ReadOnly Property MachModeCommand As ICommand
|
||||
Get
|
||||
If m_cmdMachMode Is Nothing Then
|
||||
m_cmdMachMode = New Command(AddressOf MachMode)
|
||||
End If
|
||||
Return m_cmdMachMode
|
||||
End Get
|
||||
End Property
|
||||
|
||||
''' <summary>
|
||||
''' Creata the new tool. This method is invoked by the NewCommand.
|
||||
''' </summary>
|
||||
Public Sub MachMode()
|
||||
' aggiorno lo stato
|
||||
If MySimul.GetMachLook() <> MCH_LOOK.ALL Then
|
||||
MySimul.SetMachLook(MCH_LOOK.ALL)
|
||||
End If
|
||||
' aggiorno lo stato della macchina e la sua visualizzazione
|
||||
EgtSetMachineLook(MySimul.GetMachLook())
|
||||
EgtDraw()
|
||||
End Sub
|
||||
|
||||
#End Region ' MachModeCommand
|
||||
|
||||
#End Region ' COMMANDS
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user