Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 88b9226bcb |
@@ -561,6 +561,8 @@ Public Class LeftPanelVM
|
|||||||
If CurrentMachine.Flow = FlowTypes.ONEBYONE Then
|
If CurrentMachine.Flow = FlowTypes.ONEBYONE Then
|
||||||
MyMachGroupVM.UpdateProduceIsEnabledForAll()
|
MyMachGroupVM.UpdateProduceIsEnabledForAll()
|
||||||
End If
|
End If
|
||||||
|
' aggiorno log macchina
|
||||||
|
Map.refMachineLogPageVM.UpdateMachineLogList(False)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
#End Region ' DoneRawPart
|
#End Region ' DoneRawPart
|
||||||
@@ -800,6 +802,8 @@ Public Class LeftPanelVM
|
|||||||
Next
|
Next
|
||||||
SetDonePart(SelMachGroup, SelMachGroup.SelPart)
|
SetDonePart(SelMachGroup, SelMachGroup.SelPart)
|
||||||
Map.refProjectVM.SupervisorMachGroupPanelVM.SelectedMachGroup = SelMachGroup
|
Map.refProjectVM.SupervisorMachGroupPanelVM.SelectedMachGroup = SelMachGroup
|
||||||
|
' aggiorno log macchina
|
||||||
|
Map.refMachineLogPageVM.UpdateMachineLogList(False)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Public Sub SetDonePart(MachGroup As MyMachGroupVM, Part As PartVM)
|
Public Sub SetDonePart(MachGroup As MyMachGroupVM, Part As PartVM)
|
||||||
|
|||||||
@@ -569,6 +569,8 @@ Public Class MachManaging
|
|||||||
' scrivo evento inizio MachGroup su DB
|
' scrivo evento inizio MachGroup su DB
|
||||||
DbControllers.m_LogMachineController.Create(LogEvent.CreateMachGroupStateLog(dtStart, nP_Prod, nP_Machgroup, nP_State, DbControllers.SupervisorId))
|
DbControllers.m_LogMachineController.Create(LogEvent.CreateMachGroupStateLog(dtStart, nP_Prod, nP_Machgroup, nP_State, DbControllers.SupervisorId))
|
||||||
End If
|
End If
|
||||||
|
' flag di aggiornamento log macchina
|
||||||
|
Map.refMachineLogPageVM.UpdateMachineLogList(False)
|
||||||
' attesa per essere sicuro che abbia scritto e riletto variabili
|
' attesa per essere sicuro che abbia scritto e riletto variabili
|
||||||
Threading.Thread.Sleep(300)
|
Threading.Thread.Sleep(300)
|
||||||
ElseIf nP_State = PartState.END_ Then
|
ElseIf nP_State = PartState.END_ Then
|
||||||
@@ -678,6 +680,8 @@ Public Class MachManaging
|
|||||||
Map.refLeftPanelVM.PrintLabel(MachGroup, Part)
|
Map.refLeftPanelVM.PrintLabel(MachGroup, Part)
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
' flag di aggiornamento log macchina
|
||||||
|
Map.refMachineLogPageVM.UpdateMachineLogList(False)
|
||||||
' attesa per essere sicuro che abbia scritto e riletto variabili
|
' attesa per essere sicuro che abbia scritto e riletto variabili
|
||||||
Threading.Thread.Sleep(300)
|
Threading.Thread.Sleep(300)
|
||||||
End If
|
End If
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ Imports EgtBEAMWALL.Core.MachLog
|
|||||||
Public Class MachineLogPageVM
|
Public Class MachineLogPageVM
|
||||||
Inherits VMBase
|
Inherits VMBase
|
||||||
|
|
||||||
|
Private m_Lock_LogList As New Object
|
||||||
|
|
||||||
|
Private m_MachineLog_Timer As New DispatcherTimer
|
||||||
|
|
||||||
Private Enum DayTypes As Integer
|
Private Enum DayTypes As Integer
|
||||||
TODAY = 0
|
TODAY = 0
|
||||||
YESTERDAY = 1
|
YESTERDAY = 1
|
||||||
@@ -131,7 +135,7 @@ Public Class MachineLogPageVM
|
|||||||
End If
|
End If
|
||||||
NotifyPropertyChanged(NameOf(Date_Visibility))
|
NotifyPropertyChanged(NameOf(Date_Visibility))
|
||||||
' aggiorno lista da Db
|
' aggiorno lista da Db
|
||||||
UpdateMachineLogList()
|
UpdateMachineLogList(True)
|
||||||
End Set
|
End Set
|
||||||
End Property
|
End Property
|
||||||
|
|
||||||
@@ -145,7 +149,7 @@ Public Class MachineLogPageVM
|
|||||||
Dim lStartDate As Long = m_dtStartDate.ToFileTimeUtc()
|
Dim lStartDate As Long = m_dtStartDate.ToFileTimeUtc()
|
||||||
WriteMainPrivateProfileString(S_MACHINELOGFILTER, K_STARTDATE, lStartDate.ToString())
|
WriteMainPrivateProfileString(S_MACHINELOGFILTER, K_STARTDATE, lStartDate.ToString())
|
||||||
' aggiorno lista da Db
|
' aggiorno lista da Db
|
||||||
UpdateMachineLogList()
|
UpdateMachineLogList(True)
|
||||||
End Set
|
End Set
|
||||||
End Property
|
End Property
|
||||||
|
|
||||||
@@ -159,7 +163,7 @@ Public Class MachineLogPageVM
|
|||||||
Dim lEndDate As Long = m_dtEndDate.ToFileTimeUtc()
|
Dim lEndDate As Long = m_dtEndDate.ToFileTimeUtc()
|
||||||
WriteMainPrivateProfileString(S_MACHINELOGFILTER, K_ENDDATE, lEndDate.ToString())
|
WriteMainPrivateProfileString(S_MACHINELOGFILTER, K_ENDDATE, lEndDate.ToString())
|
||||||
' aggiorno lista da Db
|
' aggiorno lista da Db
|
||||||
UpdateMachineLogList()
|
UpdateMachineLogList(True)
|
||||||
End Set
|
End Set
|
||||||
End Property
|
End Property
|
||||||
|
|
||||||
@@ -263,6 +267,9 @@ Public Class MachineLogPageVM
|
|||||||
m_dtEndDate = If(lEndDate > 0, DateTime.FromFileTimeUtc(lEndDate), DateTime.Today)
|
m_dtEndDate = If(lEndDate > 0, DateTime.FromFileTimeUtc(lEndDate), DateTime.Today)
|
||||||
m_Date_Visibility = Visibility.Visible
|
m_Date_Visibility = Visibility.Visible
|
||||||
End Select
|
End Select
|
||||||
|
m_MachineLog_Timer.Interval = TimeSpan.FromMilliseconds(100)
|
||||||
|
AddHandler m_MachineLog_Timer.Tick, AddressOf MachineLog_Timer_Tick
|
||||||
|
m_MachineLog_Timer.Start()
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
#End Region ' CONSTRUCTORS
|
#End Region ' CONSTRUCTORS
|
||||||
@@ -305,21 +312,69 @@ Public Class MachineLogPageVM
|
|||||||
m_colMachineLog_Description.ColumnVisibility = Visibility.Collapsed
|
m_colMachineLog_Description.ColumnVisibility = Visibility.Collapsed
|
||||||
m_colMachineLog_SupervisorId.ColumnVisibility = Visibility.Collapsed
|
m_colMachineLog_SupervisorId.ColumnVisibility = Visibility.Collapsed
|
||||||
End If
|
End If
|
||||||
UpdateMachineLogList()
|
UpdateMachineLogList(True)
|
||||||
m_MachineLogList_View = CollectionViewSource.GetDefaultView(m_MachineLogList)
|
m_MachineLogList_View = CollectionViewSource.GetDefaultView(m_MachineLogList)
|
||||||
m_MachineLogList_View.Filter = AddressOf MachineLogFilter
|
m_MachineLogList_View.Filter = AddressOf MachineLogFilter
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Friend Sub UpdateMachineLogList()
|
' indice di aggiornamento della lista rispetto a Db
|
||||||
|
Private m_nUpdateIndex As Integer
|
||||||
|
' indice di ricaricamento completo della lista dal Db
|
||||||
|
Private m_nRefreshIndex As Integer
|
||||||
|
' indice dell'ultimo update/refresh
|
||||||
|
Private m_nLastLogUpdate As Integer
|
||||||
|
|
||||||
|
Friend Sub UpdateMachineLogList(bRefresh As Boolean)
|
||||||
|
Dim nMaxIndex As Integer = Math.Max(m_nUpdateIndex, m_nRefreshIndex)
|
||||||
|
If bRefresh Then
|
||||||
|
m_nRefreshIndex = nMaxIndex + 1
|
||||||
|
Else
|
||||||
|
m_nUpdateIndex = nMaxIndex + 1
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub MachineLog_Timer_Tick(sender As Object, e As EventArgs)
|
||||||
|
SyncLock m_Lock_LogList
|
||||||
|
Dim nRefresh As Integer = m_nRefreshIndex
|
||||||
|
Dim nUpdate As Integer = m_nUpdateIndex
|
||||||
|
If nRefresh > m_nLastLogUpdate Then
|
||||||
|
m_nLastLogUpdate = nRefresh
|
||||||
|
UpdateFromDb(True)
|
||||||
|
ElseIf nUpdate > m_nLastLogUpdate Then
|
||||||
|
m_nLastLogUpdate = nUpdate
|
||||||
|
UpdateFromDb(False)
|
||||||
|
End If
|
||||||
|
End SyncLock
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Friend Sub UpdateFromDb(bRefresh As Boolean)
|
||||||
'm_MachineLogList = New ObservableCollection(Of LogEvent)(DbControllers.m_LogMachineController.GetCoreDesc(DateTime.Now - TimeSpan.FromDays(300), DateTime.Now).Select(Of LogEvent)(Function(x) New LogEvent(x)).ToList())
|
'm_MachineLogList = New ObservableCollection(Of LogEvent)(DbControllers.m_LogMachineController.GetCoreDesc(DateTime.Now - TimeSpan.FromDays(300), DateTime.Now).Select(Of LogEvent)(Function(x) New LogEvent(x)).ToList())
|
||||||
|
Dim DbList As List(Of LogEvent)
|
||||||
Select Case m_SelDayType
|
Select Case m_SelDayType
|
||||||
Case DayTypes.TODAY
|
|
||||||
m_MachineLogList = New ObservableCollection(Of LogEvent)(DbControllers.m_LogMachineController.GetCoreDesc(DateTime.Today, DateTime.Today + TimeSpan.FromDays(1)).Select(Of LogEvent)(Function(x) New LogEvent(x)).ToList())
|
|
||||||
Case DayTypes.YESTERDAY
|
|
||||||
m_MachineLogList = New ObservableCollection(Of LogEvent)(DbControllers.m_LogMachineController.GetCoreDesc(DateTime.Today - TimeSpan.FromDays(1), DateTime.Today).Select(Of LogEvent)(Function(x) New LogEvent(x)).ToList())
|
|
||||||
Case DayTypes.PERIOD
|
Case DayTypes.PERIOD
|
||||||
m_MachineLogList = New ObservableCollection(Of LogEvent)(DbControllers.m_LogMachineController.GetCoreDesc(m_dtStartDate, m_dtEndDate + TimeSpan.FromDays(1)).Select(Of LogEvent)(Function(x) New LogEvent(x)).ToList())
|
DbList = DbControllers.m_LogMachineController.GetCoreDesc(m_dtStartDate, m_dtEndDate + TimeSpan.FromDays(1)).Select(Of LogEvent)(Function(x) New LogEvent(x)).ToList()
|
||||||
|
Case DayTypes.YESTERDAY
|
||||||
|
DbList = DbControllers.m_LogMachineController.GetCoreDesc(DateTime.Today - TimeSpan.FromDays(1), DateTime.Today).Select(Of LogEvent)(Function(x) New LogEvent(x)).ToList()
|
||||||
|
Case Else ' DayTypes.TODAY
|
||||||
|
DbList = DbControllers.m_LogMachineController.GetCoreDesc(DateTime.Today, DateTime.Today + TimeSpan.FromDays(1)).Select(Of LogEvent)(Function(x) New LogEvent(x)).ToList()
|
||||||
End Select
|
End Select
|
||||||
|
If bRefresh OrElse m_MachineLogList.Count < 1 Then
|
||||||
|
m_MachineLogList = New ObservableCollection(Of LogEvent)(DbList)
|
||||||
|
Else
|
||||||
|
' cerco in lista Db ultimo elemento della mia lista
|
||||||
|
Dim LastItem As LogEvent = m_MachineLogList(0)
|
||||||
|
Dim CommonItem As LogEvent = DbList.FirstOrDefault(Function(x) x.EventDateTime = LastItem.EventDateTime AndAlso x.EventType = LastItem.EventType AndAlso x.SupervisorId = LastItem.SupervisorId AndAlso x.Value = LastItem.Value)
|
||||||
|
Dim nCommonItemIndex As Integer
|
||||||
|
If Not IsNothing(CommonItem) Then
|
||||||
|
nCommonItemIndex = DbList.IndexOf(CommonItem)
|
||||||
|
End If
|
||||||
|
' aggiorno i successivi
|
||||||
|
If nCommonItemIndex >= 0 Then
|
||||||
|
For Index = nCommonItemIndex - 1 To 0 Step -1
|
||||||
|
m_MachineLogList.Insert(0, DbList(Index))
|
||||||
|
Next
|
||||||
|
End If
|
||||||
|
End If
|
||||||
NotifyPropertyChanged(NameOf(MachineLogList))
|
NotifyPropertyChanged(NameOf(MachineLogList))
|
||||||
m_MachineLogList_View = CollectionViewSource.GetDefaultView(m_MachineLogList)
|
m_MachineLogList_View = CollectionViewSource.GetDefaultView(m_MachineLogList)
|
||||||
m_MachineLogList_View.Filter = AddressOf MachineLogFilter
|
m_MachineLogList_View.Filter = AddressOf MachineLogFilter
|
||||||
@@ -347,7 +402,7 @@ Public Class MachineLogPageVM
|
|||||||
''' Execute the Open. This method is invoked by the OpenCommand.
|
''' Execute the Open. This method is invoked by the OpenCommand.
|
||||||
''' </summary>
|
''' </summary>
|
||||||
Friend Sub Refresh()
|
Friend Sub Refresh()
|
||||||
UpdateMachineLogList()
|
UpdateMachineLogList(False)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
#End Region ' Refresh
|
#End Region ' Refresh
|
||||||
|
|||||||
Reference in New Issue
Block a user