- aggiunta funzione OpenProduction

- migliorata gestione conversione date in string con convertitori da libreria
- correzione in PlgGetNextDoor to manage also folders for ddf
- in modalita' debug se reset azzero stato macchina
- se in reset non aggiorno stati porte
- in RestartWnd aggiunta lista porte con stato da sistemare e gestito bottone EmptyMachine
- corretta scrittura date ed altri parametri su Json
This commit is contained in:
Emmanuele Sassi
2025-02-26 16:19:46 +01:00
parent bb8c88cfbc
commit 27f1b9b99d
11 changed files with 475 additions and 103 deletions
@@ -22,6 +22,7 @@ Module ConstIni
Public Const K_DDFDIR As String = "DDFDir"
Public Const K_DDTDIR As String = "DDTDir"
Public Const K_GENDDFDIR As String = "GenDDFDir"
Public Const K_CSV As String = "CSV"
Public Const K_CSVOUTPUT As String = "CSVOutput"
Public Const K_RESTART_WINPLACE As String = "RestartWinPlace"
@@ -39,6 +40,12 @@ Module ConstIni
Public Const K_MANUALADDEDDOORNAME As String = "ManualAddedDoorName"
Public Const K_DELIMITER As String = "Delimiter"
Public Const S_PRODUCTION As String = "Production"
Public Const K_CUSTOMER As String = "Customer"
Public Const K_ORDER As String = "Order"
Public Const K_SEQUENCE As String = "Sequence"
Public Const K_TICKET As String = "Ticket"
Public Const S_DEBUG As String = "Debug"
Public Const K_VARIABLELIST As String = "VariableList"
Public Const K_VARIABLEONDRAW As String = "VariableOnDraw"
@@ -110,6 +110,13 @@
<Image Source="../Resources/DoorListPage/Verify.png"
Style="{StaticResource Button_Image}"/>
</Button>
<Button ToolTip="Open production CSV file"
Command="{Binding OpenProduction_Command}"
IsEnabled="{Binding bExecButton_IsEnabled}"
Style="{StaticResource DoorList_Button}">
<Image Source="../Resources/DoorListPage/OpenProduction.png"
Style="{StaticResource Button_Image}"/>
</Button>
<TextBlock Text="{Binding sExecPercentage}"
VerticalAlignment="Center"
Margin="10,0,5,0"
@@ -99,6 +99,7 @@ Public Class DoorListPageVM
Private m_cmdProduceAll As ICommand
Private m_cmdResetProductionQueue As ICommand
Private m_cmdVerify As ICommand
Private m_cmdOpenProduction As ICommand
#Region "CONSTRUCTOR"
@@ -1121,6 +1122,89 @@ Public Class DoorListPageVM
#End Region ' Verify
#Region "OpenProduction"
Public ReadOnly Property OpenProduction_Command As ICommand
Get
If m_cmdOpenProduction Is Nothing Then
m_cmdOpenProduction = New Command(AddressOf OpenProduction)
End If
Return m_cmdOpenProduction
End Get
End Property
Public Sub OpenProduction()
Dim sDir As String = String.Empty
'GetMainPrivateProfileString(S_GENERAL, K_LASTIMPDIR, "", sDir)
Dim OpenFileDialog As New Microsoft.Win32.OpenFileDialog() With {
.DefaultExt = ".csv",
.Filter = "CSV (*.csv)|*.csv",
.InitialDirectory = If(Directory.Exists(sDir), sDir, ""),
.CheckFileExists = True,
.ValidateNames = True}
If OpenFileDialog.ShowDialog() Then
Dim sProductionCsvPath As String = OpenFileDialog.FileName
Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(sProductionCsvPath)
MyReader.TextFieldType = FileIO.FieldType.Delimited
Dim sDelimiter As String = ""
GetPluginPrivateProfileString(S_CSV, K_DELIMITER, ";", sDelimiter)
MyReader.SetDelimiters(sDelimiter)
' leggo intestazione
Dim Headers As String() = MyReader.ReadFields()
Dim sCustomer As String = ""
Dim sOrder As String = ""
Dim sSequence As String = ""
Dim sTicket As String = ""
GetPluginPrivateProfileString(S_PRODUCTION, K_CUSTOMER, "CUST", sCustomer)
GetPluginPrivateProfileString(S_PRODUCTION, K_ORDER, "ORDER", sOrder)
GetPluginPrivateProfileString(S_PRODUCTION, K_SEQUENCE, "SEQ", sSequence)
GetPluginPrivateProfileString(S_PRODUCTION, K_TICKET, "TICKET", sTicket)
Dim nCustomerNameIndex As Integer = Array.IndexOf(Headers, sCustomer)
Dim nOrderNameIndex As Integer = Array.IndexOf(Headers, sOrder)
Dim nSequenceNameIndex As Integer = Array.IndexOf(Headers, sSequence)
Dim nTicketNameIndex As Integer = Array.IndexOf(Headers, sTicket)
If nCustomerNameIndex = -1 OrElse nOrderNameIndex = -1 OrElse nTicketNameIndex = -1 Then
Dim sMessage As String = "Error! Header not found! Csv file will not be read!"
' egtoutlog(sMessage)
MessageBox.Show(sMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Error)
Return
End If
Dim Values As String()
Dim sLineErrorList As String = ""
Dim sCsvFolderPath As String = ""
GetPluginPrivateProfileString(S_GENERAL, K_CSV, "", sCsvFolderPath)
Dim sHeaderLine As String = ""
For Index As Integer = 0 To Headers.Count - 1
sHeaderLine &= Headers(Index) & If(Index < Headers.Count - 1, ",", "")
Next
sHeaderLine &= ",DDF"
While Not MyReader.EndOfData
Try
Values = MyReader.ReadFields()
' scrivo csv per ogni riga
Dim sCsvPath As String = sCsvFolderPath & "\" & Values(nCustomerNameIndex) & "-" & Values(nOrderNameIndex) & "-" & Values(nTicketNameIndex) & ".csv"
Dim sValueLine As String = ""
For Index As Integer = 0 To Values.Count - 1
sValueLine &= Values(Index) & If(Index < Values.Count - 1, ",", "")
Next
sValueLine &= "," & Values(nCustomerNameIndex) & "-" & Values(nOrderNameIndex) & "\" & Values(nSequenceNameIndex)
File.WriteAllLines(sCsvPath, {sHeaderLine, sValueLine})
Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
Dim sMessage As String = "Line " & ex.Message & "is not valid and will be skipped."
' egtoutlog(sMessage)
sLineErrorList &= Environment.NewLine & ex.Message
End Try
End While
If Not String.IsNullOrWhiteSpace(sLineErrorList) Then
MessageBox.Show("The following lines are not valid and have been skipped:" & sLineErrorList, "Error", MessageBoxButton.OK, MessageBoxImage.Error)
End If
End Using
Verify()
End If
End Sub
#End Region ' OpenProduction
#End Region ' COMMANDS
End Class
@@ -1527,7 +1611,7 @@ Public Class Door
End Property
Public ReadOnly Property sLoadTime As String
Get
Return If(m_dtLoadTime <> DateTime.MinValue, m_dtLoadTime.ToString("yy/MM/dd hh:mm:ss"), "")
Return ConvertDateTimeToString(m_dtLoadTime)
End Get
End Property
Friend Sub SetLoadTime(LoadTime As Long)
@@ -1543,7 +1627,7 @@ Public Class Door
End Property
Public ReadOnly Property sMachining1Start As String
Get
Return If(m_dtMachining1Start <> DateTime.MinValue, m_dtMachining1Start.ToString("yy/MM/dd hh:mm:ss"), "")
Return ConvertDateTimeToString(m_dtMachining1Start)
End Get
End Property
Friend Sub SetMachining1Start(Machining1Start As Long)
@@ -1559,7 +1643,7 @@ Public Class Door
End Property
Public ReadOnly Property sMachining1End As String
Get
Return If(m_dtMachining1End <> DateTime.MinValue, m_dtMachining1End.ToString("yy/MM/dd hh:mm:ss"), "")
Return ConvertDateTimeToString(m_dtMachining1End)
End Get
End Property
Friend Sub SetMachining1End(Machining1End As Long)
@@ -1575,7 +1659,7 @@ Public Class Door
End Property
Public ReadOnly Property sMachining2Start As String
Get
Return If(m_dtMachining2Start <> DateTime.MinValue, m_dtMachining2Start.ToString("yy/MM/dd hh:mm:ss"), "")
Return ConvertDateTimeToString(m_dtMachining2Start)
End Get
End Property
Friend Sub SetMachining2Start(Machining2Start As Long)
@@ -1591,7 +1675,7 @@ Public Class Door
End Property
Public ReadOnly Property sMachining2End As String
Get
Return If(m_dtMachining2End <> DateTime.MinValue, m_dtMachining2End.ToString("yy/MM/dd hh:mm:ss"), "")
Return ConvertDateTimeToString(m_dtMachining2End)
End Get
End Property
Friend Sub SetMachining2End(Machining2End As Long)
@@ -1607,7 +1691,7 @@ Public Class Door
End Property
Public ReadOnly Property sUnloadTime As String
Get
Return If(m_dtUnloadTime <> DateTime.MinValue, m_dtUnloadTime.ToString("yy/MM/dd hh:mm:ss"), "")
Return ConvertDateTimeToString(m_dtUnloadTime)
End Get
End Property
Friend Sub SetUnloadTime(UnloadTime As Long)
@@ -209,6 +209,9 @@
<ItemGroup>
<Resource Include="Resources\DoorListPage\NotProduce.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\DoorListPage\OpenProduction.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
<PropertyGroup>
<PreBuildEvent>powershell.exe -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -File $(ProjectDir)\pre-build.ps1 -ProjectDir $(ProjectDir) -ProjectPath $(ProjectPath)</PreBuildEvent>
+3 -2
View File
@@ -1,4 +1,5 @@
Imports KeraLua
Imports System.IO
Imports Effector.Plugin.Lib
Public Module Lua_General
@@ -110,8 +111,8 @@ Public Module Lua_General
If Not IsNothing(NextDoor) Then
' restituisco il risultato
LuaSetParam(state, NextDoor.nId)
' Dim sGenDDFName As String = Path.GetFileNameWithoutExtension(NextDoor.sDDFName) & "_" & NextDoor.nId & ".ddf"
LuaSetParam(state, NextDoor.sDDFName & "_" & NextDoor.nId)
LuaSetParam(state, If(Not String.IsNullOrWhiteSpace(Path.GetDirectoryName(NextDoor.sDDFName)), Path.GetDirectoryName(NextDoor.sDDFName) & "_", "") & Path.GetFileNameWithoutExtension(NextDoor.sDDFName) & "_" & NextDoor.nId & ".ddf")
'LuaSetParam(state, NextDoor.sDDFName & "_" & NextDoor.nId)
Return 2
End If
Return 0
@@ -245,6 +245,18 @@ Public Class MachinePageVM
End If
Next
End If
' se reset
For nMachineIndex = 1 To 2
Dim nMachineId As Integer = nMachineIndex
Dim Reset As Variable = m_VariableList.FirstOrDefault(Function(x) x.sName = "@RESET_ON" AndAlso x.nMachine = nMachineId)
If Not IsNothing(Reset) AndAlso Reset.nValue = 1 Then
Dim MachineState As Variable = m_VariableList.FirstOrDefault(Function(x) x.sName = "@STATE" AndAlso x.nMachine = nMachineId)
Dim nIndex As Integer = -1
Integer.TryParse(MachineState.sIndex, nIndex)
Map.refSupervisorFunction.ComWriteShortVar(nIndex, 0, nMachineIndex)
End If
Next
End If
' leggo stato calcolo da lua
Dim nState As Integer = -1
@@ -263,6 +275,10 @@ Public Class MachinePageVM
SetNewDoorState(nState)
End If
m_LuaDoorList.Clear()
Dim bM1Reset As Boolean = False
LuaGetGlobVar("bReset_M1", bM1Reset)
Dim bM2Reset As Boolean = False
LuaGetGlobVar("bReset_M2", bM2Reset)
For nDoorIndex = 1 To 10
Dim nId As Integer = -1
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".nId", nId)
@@ -297,10 +313,10 @@ Public Class MachinePageVM
Dim lUnloadTime As Long = 0
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".nUnloadTime", lUnloadTime)
m_LuaDoorList.Add(New LuaDoor(nId, nCircIndex, nDoorState, nDoorPosition, sDoorCode, sDoorDescription, sDDFName, sCSVName, sM1CNPath, sM2CNPath, lLoadTime, lMachining1Start, lMachining1End, lMachining2Start, lMachining2End, lUnloadTime))
If nId > 0 Then
If Not bM1Reset AndAlso Not bM2Reset AndAlso nId > 0 Then
' aggiorno dati in lista porte
Dim Door As Door = Map.refDoorListPageVM.DoorList.FirstOrDefault(Function(x) x.nId = nId)
If nDoorState <> Door.nProdState Then
If Not IsNothing(Door) AndAlso nDoorState <> Door.nProdState Then
Door.SetProdState(nDoorState)
If lLoadTime > 0 Then Door.SetLoadTime(lLoadTime)
If lMachining1Start > 0 Then Door.SetMachining1Start(lMachining1Start)
@@ -838,42 +854,42 @@ Public Class LuaDoor
Private m_dtLoadTime As DateTime
Public ReadOnly Property sLoadTime As String
Get
Return m_dtLoadTime.ToString("yy/MM/dd HH:mm:ss")
Return ConvertDateTimeToString(m_dtLoadTime)
End Get
End Property
Private m_dtMachining1Start As DateTime
Public ReadOnly Property sMachining1Start As String
Get
Return m_dtMachining1Start.ToString("yy/MM/dd HH:mm:ss")
Return ConvertDateTimeToString(m_dtMachining1Start)
End Get
End Property
Private m_dtMachining1End As DateTime
Public ReadOnly Property sMachining1End As String
Get
Return m_dtMachining1End.ToString("yy/MM/dd HH:mm:ss")
Return ConvertDateTimeToString(m_dtMachining1End)
End Get
End Property
Private m_dtMachining2Start As DateTime
Public ReadOnly Property sMachining2Start As String
Get
Return m_dtMachining2Start.ToString("yy/MM/dd HH:mm:ss")
Return ConvertDateTimeToString(m_dtMachining2Start)
End Get
End Property
Private m_dtMachining2End As DateTime
Public ReadOnly Property sMachining2End As String
Get
Return m_dtMachining2End.ToString("yy/MM/dd HH:mm:ss")
Return ConvertDateTimeToString(m_dtMachining2End)
End Get
End Property
Private m_dtUnloadTime As DateTime
Public ReadOnly Property sUnloadTime As String
Get
Return m_dtUnloadTime.ToString("yy/MM/dd HH:mm:ss")
Return ConvertDateTimeToString(m_dtUnloadTime)
End Get
End Property
Binary file not shown.

After

Width:  |  Height:  |  Size: 424 B

@@ -19,6 +19,7 @@
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Image Source="{Binding sMachineImagePath}"
Stretch="Uniform"/>
@@ -204,66 +205,30 @@
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<ItemsControl Grid.Row="2"
ItemsSource="{Binding DoorToBeFixedList}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Text="{Binding nId}"
TextAlignment="Center"/>
<ComboBox Grid.Row="1"
ItemsSource="{Binding StateList}"
SelectedItem="{Binding SelState}"/>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
<!--<ItemsControl ItemsSource="{Binding RestartDoorList}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Rows="1"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Visibility="{Binding nState, Converter={StaticResource StateToVisibilityConverter}}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Column="0"
Grid.Row="0"
Text="Id"/>
<TextBlock Grid.Column="1"
Grid.Row="0"
Text="{Binding nId}"/>
<TextBlock Grid.Column="0"
Grid.Row="1"
Text="Circular Index"/>
<TextBlock Grid.Column="1"
Grid.Row="1"
Text="{Binding nCircIndex}"/>
<TextBlock Grid.Column="0"
Grid.Row="2"
Text="State"/>
<TextBlock Grid.Column="1"
Grid.Row="2"
Text="{Binding nState}"/>
<ComboBox Grid.Column="1"
Grid.Row="2"
ItemsSource="{Binding DoorStateList}"
SelectedItem="{Binding SelDoorState}"/>
<TextBlock Grid.Column="0"
Grid.Row="3"
Text="DDF Name"/>
<TextBlock Grid.Column="1"
Grid.Row="3"
Text="{Binding sDDFName}"/>
<TextBlock Grid.Column="0"
Grid.Row="4"
Text="CSV Name"/>
<TextBlock Grid.Column="1"
Grid.Row="4"
Text="{Binding sCSVName}"/>
<TextBlock Text="Id"/>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>-->
<StackPanel Grid.Row="1"
Orientation="Horizontal"
Margin="20"
@@ -271,9 +236,10 @@
<Button Content="Ok"
Command="{Binding Ok_Command}"
Margin="0,0,10,0"
Visibility="{Binding OkBtn_Visibility}"
Style="{StaticResource Restart_Button}"/>
<Button Grid.Column="1"
Content="Empty Line"
Content="Empty Machine"
Command="{Binding Empty_Command}"
Margin="10,0,0,0"
Style="{StaticResource Restart_Button}"/>
@@ -53,12 +53,26 @@ Public Class RestartWndVM
End Get
End Property
Private m_DoorToBeFixedList As New ObservableCollection(Of DoorToBeFixed)
Public ReadOnly Property DoorToBeFixedList As ObservableCollection(Of DoorToBeFixed)
Get
Return m_DoorToBeFixedList
End Get
End Property
Public ReadOnly Property VariableList As ObservableCollection(Of Variable)
Get
Return Map.refMachinePageVM.VariableList
End Get
End Property
Private m_OkBtn_Visibility As Visibility = True
Public ReadOnly Property OkBtn_Visibility As Visibility
Get
Return m_OkBtn_Visibility
End Get
End Property
' Definizione comandi
Private m_cmdOk As ICommand
Private m_cmdEmpty As ICommand
@@ -101,12 +115,124 @@ Public Class RestartWndVM
Dim nCircindex As Integer = 0
GetVariableValueFromName(nMachineIndex, "@DOORN_S" & nPositionIndex.ToString(), nCircindex)
If nCircindex <> 0 Then
m_DoorOnMachineArray(nPositionIndex) = New RestartDoor(JsonLuaDoorList(nCircindex - 1))
If Not IsNothing(JsonLuaDoorList) AndAlso JsonLuaDoorList(nCircindex - 1).nId > 0 Then
m_DoorOnMachineArray(nPositionIndex) = New RestartDoor(JsonLuaDoorList(nCircindex - 1))
Else
m_OkBtn_Visibility = Visibility.Collapsed
NotifyPropertyChanged(NameOf(OkBtn_Visibility))
End If
End If
End If
Next
NotifyPropertyChanged(NameOf(DoorOnMachineArray))
' percorro la lista lua
If Not IsNothing(JsonLuaDoorList) Then
For LuaDoorIndex = 0 To JsonLuaDoorList.Count - 1
Dim LuaDoor As JsonLuaDoor = JsonLuaDoorList(LuaDoorIndex)
If nMachineIndex = 1 Then
' verifico che in base allo stato siano in una posizione conforme, altrimenti li azzero
Select Case LuaDoor.nState
Case 2 ' SENT_1
Dim nCircIndex0 As Integer = 0
GetVariableValueFromName(nMachineIndex, "@DOORN_S0", nCircIndex0)
If nCircIndex0 <> LuaDoor.nId Then
ResetLuaDoor(LuaDoorIndex, JsonLuaDoorList)
End If
Case 3 ' START_MACHINING_1
Dim nCircIndex0 As Integer = 0
GetVariableValueFromName(nMachineIndex, "@DOORN_S0", nCircIndex0)
Dim nCircIndex1 As Integer = 0
GetVariableValueFromName(nMachineIndex, "@DOORN_S1", nCircIndex1)
Dim nCircIndex2 As Integer = 0
GetVariableValueFromName(nMachineIndex, "@DOORN_S2", nCircIndex2)
If nCircIndex0 <> LuaDoor.nId AndAlso nCircIndex1 <> LuaDoor.nId AndAlso nCircIndex2 <> LuaDoor.nId Then
ResetLuaDoor(LuaDoorIndex, JsonLuaDoorList)
End If
Case 4 ' MACHINED_1
Dim nCircIndex2 As Integer = 0
GetVariableValueFromName(nMachineIndex, "@DOORN_S2", nCircIndex2)
Dim nCircIndex3 As Integer = 0
GetVariableValueFromName(nMachineIndex, "@DOORN_S3", nCircIndex3)
Dim nCircIndex4 As Integer = 0
GetVariableValueFromName(nMachineIndex, "@DOORN_S4", nCircIndex4)
If nCircIndex2 <> LuaDoor.nId AndAlso nCircIndex3 <> LuaDoor.nId AndAlso nCircIndex4 <> LuaDoor.nId Then
ResetLuaDoor(LuaDoorIndex, JsonLuaDoorList)
End If
End Select
ElseIf nMachineIndex = 2 Then
Select Case LuaDoor.nState
Case 5 ' SENT_2
Dim nCircIndex0 As Integer = 0
GetVariableValueFromName(nMachineIndex, "@DOORN_S0", nCircIndex0)
If nCircIndex0 <> LuaDoor.nId Then
ResetLuaDoor(LuaDoorIndex, JsonLuaDoorList)
End If
Case 6 ' START_MACHINING_2
Dim nCircIndex0 As Integer = 0
GetVariableValueFromName(nMachineIndex, "@DOORN_S0", nCircIndex0)
Dim nCircIndex1 As Integer = 0
GetVariableValueFromName(nMachineIndex, "@DOORN_S1", nCircIndex1)
Dim nCircIndex2 As Integer = 0
GetVariableValueFromName(nMachineIndex, "@DOORN_S2", nCircIndex2)
If nCircIndex0 <> LuaDoor.nId AndAlso nCircIndex1 <> LuaDoor.nId AndAlso nCircIndex2 <> LuaDoor.nId Then
ResetLuaDoor(LuaDoorIndex, JsonLuaDoorList)
End If
Case 7 ' MACHINED_2
Dim nCircIndex2 As Integer = 0
GetVariableValueFromName(nMachineIndex, "@DOORN_S2", nCircIndex2)
Dim nCircIndex3 As Integer = 0
GetVariableValueFromName(nMachineIndex, "@DOORN_S3", nCircIndex3)
Dim nCircIndex4 As Integer = 0
GetVariableValueFromName(nMachineIndex, "@DOORN_S4", nCircIndex4)
If nCircIndex2 <> LuaDoor.nId AndAlso nCircIndex3 <> LuaDoor.nId AndAlso nCircIndex4 <> LuaDoor.nId Then
ResetLuaDoor(LuaDoorIndex, JsonLuaDoorList)
End If
Case 8 ' UNLOADED
ResetLuaDoor(LuaDoorIndex, JsonLuaDoorList)
End Select
End If
Next
End If
' aggiorno file backup del lua
If File.Exists(sBackupFilePath) Then
Try
File.Delete(sBackupFilePath)
Catch ex As Exception
End Try
Dim sWriteFile As String = JsonConvert.SerializeObject(JsonLuaDoorList, Formatting.Indented)
File.WriteAllText(sBackupFilePath, sWriteFile)
End If
' verifico se in lista porte ci sono porte non gestite
For DoorIndex = 0 To Map.refDoorListPageVM.DoorList.Count - 1
Dim CurrDoor As Door = Map.refDoorListPageVM.DoorList(DoorIndex)
Select Case CurrDoor.nState
Case Door.DoorStates.PRODUCED
Continue For
Case Door.DoorStates.MACHINE_2_START
If nMachineIndex = 1 Then Continue For
' cerco porta tra quelle in restart
If Not IdIsInRestartList(CurrDoor.nId) Then
m_DoorToBeFixedList.Add(New DoorToBeFixed(CurrDoor))
End If
Case Door.DoorStates.MACHINE_1_START
If nMachineIndex = 2 Then Continue For
' cerco porta tra quelle in restart
If Not IdIsInRestartList(CurrDoor.nId) Then
m_DoorToBeFixedList.Add(New DoorToBeFixed(CurrDoor))
End If
Case Door.DoorStates.ON_LOAD_STATION
If nMachineIndex = 2 Then Continue For
' cerco porta tra quelle in restart
If Not IdIsInRestartList(CurrDoor.nId) Then
m_DoorToBeFixedList.Add(New DoorToBeFixed(CurrDoor))
End If
End Select
Next
'If File.Exists(sBackupFilePath) Then
' Dim sReadedFile As String = File.ReadAllText(sBackupFilePath)
@@ -136,6 +262,18 @@ Public Class RestartWndVM
m_sMachineImagePath = sResourcesDirPath & "\Multiax-C1223Ripartenza.png"
End Sub
Private Function IdIsInRestartList(nId As Integer) As Boolean
For Each Door In m_DoorOnMachineArray
If IsNothing(Door) Then Continue For
If Door.nId = nId Then Return True
Next
Return False
End Function
Private Sub ResetLuaDoor(Index As Integer, LuaDoorList As List(Of JsonLuaDoor))
LuaDoorList(Index) = New JsonLuaDoor(0, LuaDoorList(Index).nCircIndex, 0, "", "", "", "", "", "", 0, 0, 0, 0, 0, 0)
End Sub
#End Region ' CONSTRUCTOR
#Region "METHODS"
@@ -188,9 +326,44 @@ Public Class RestartWndVM
End Property
Public Sub Ok()
' se ci sono porte da sistemare
If m_DoorToBeFixedList.Count > 0 Then
' verifico se devo cambiarne l'ordine
For Each ToBeFixedDoor In m_DoorToBeFixedList
Dim Door As Door = Map.refDoorListPageVM.DoorList.FirstOrDefault(Function(x) x.nId = ToBeFixedDoor.nId)
If ToBeFixedDoor.SelState = Door.DoorStates.NOTPRODUCE Then
Dim DoorIndex As Integer = Map.refDoorListPageVM.DoorList.IndexOf(Door)
For Index = 0 To Map.refDoorListPageVM.DoorList.Count - 1
If Map.refDoorListPageVM.DoorList(Index).nState > Door.DoorStates.READY_FOR_PRODUCTION Then
Map.refDoorListPageVM.DoorList.Move(DoorIndex, If(Index > 0, Index - 1, 0))
Exit For
End If
Next
Door.SetState(Door.DoorStates.NOTPRODUCE)
ElseIf ToBeFixedDoor.SelState = Door.DoorStates.READY_FOR_PRODUCTION Then
Door.SetState(Door.DoorStates.READY_FOR_PRODUCTION)
Door.SetProdState(Door.DoorProdStates.NOT_INIT)
'Door.SetLoadTime(0)
'Door.SetMachining1Start(0)
'Door.SetMachining1End(0)
'Door.SetMachining2Start(0)
'Door.SetMachining2End(0)
'Door.SetUnloadTime(0)
End If
Next
End If
Map.refDoorListPageVM.NotifyPropertyChanged(NameOf(Map.refDoorListPageVM.DoorList))
RaiseEvent m_CloseWindow(True)
End Sub
Private Function IdIsInToBeFixedList(nId As Integer) As Boolean
For Each Door In m_DoorToBeFixedList
If IsNothing(Door) Then Continue For
If Door.nId = nId Then Return True
Next
Return False
End Function
#End Region ' Ok
#Region "Empty"
@@ -205,8 +378,40 @@ Public Class RestartWndVM
End Property
Public Sub Empty()
Map.refDoorListPageVM.ResetProductionQueue()
Map.refDoorListPageVM.WriteBackup()
Dim sDoorToRemove As String = ""
For DoorIndex As Integer = 0 To m_DoorOnMachineArray.Count - 1
Dim DoorToRemove As RestartDoor = m_DoorOnMachineArray(DoorIndex)
If Not IsNothing(DoorToRemove) Then
sDoorToRemove &= "- " & DoorToRemove.nId & DoorToRemove.sCSVName & If(DoorIndex > m_DoorOnMachineArray.Count - 1, Environment.NewLine, "")
End If
Next
MessageBox.Show("Are you sure you want to empty the machine?" & Environment.NewLine &
If(Not String.IsNullOrWhiteSpace(sDoorToRemove), "You have to remove doors:" & Environment.NewLine & sDoorToRemove, "") &
"You have to reset the machine and then restart it.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning)
' se ci sono porte sulla macchina
If m_DoorOnMachineArray.Count > 0 Then
For Each DoorOnmachine In m_DoorOnMachineArray
If Not IsNothing(DoorOnmachine) Then
Dim Door As Door = Map.refDoorListPageVM.DoorList.FirstOrDefault(Function(x) x.nId = DoorOnmachine.nId)
If Not IsNothing(Door) Then
Door.SetState(Door.DoorStates.READY_FOR_PRODUCTION)
Door.SetProdState(Door.DoorProdStates.NOT_INIT)
End If
End If
Next
End If
' se ci sono porte da sistemare
If m_DoorToBeFixedList.Count > 0 Then
' verifico se devo cambiarne l'ordine
For Each ToBeFixedDoor In m_DoorToBeFixedList
Dim Door As Door = Map.refDoorListPageVM.DoorList.FirstOrDefault(Function(x) x.nId = ToBeFixedDoor.nId)
If Not IsNothing(Door) Then
Door.SetState(Door.DoorStates.READY_FOR_PRODUCTION)
Door.SetProdState(Door.DoorProdStates.NOT_INIT)
End If
Next
End If
' imposto stato di reset
RaiseEvent m_CloseWindow(False)
End Sub
@@ -249,6 +454,40 @@ Public Class VariableNameToVisibilityConverter
End Class
Public Class DoorToBeFixed
Private m_nId As Integer = -1
Public ReadOnly Property nId As Integer
Get
Return m_nId
End Get
End Property
Private m_StateList As New ObservableCollection(Of Door.DoorStates)
Public ReadOnly Property StateList As ObservableCollection(Of Door.DoorStates)
Get
Return m_StateList
End Get
End Property
Private m_SelState As Door.DoorStates
Public Property SelState As Door.DoorStates
Get
Return m_SelState
End Get
Set(value As Door.DoorStates)
m_SelState = value
End Set
End Property
Sub New(Door As Door)
m_nId = Door.nId
m_StateList = New ObservableCollection(Of Door.DoorStates)({Door.DoorStates.READY_FOR_PRODUCTION, Door.DoorStates.NOTPRODUCE})
m_SelState = Door.DoorStates.NOTPRODUCE
End Sub
End Class
Public Class RestartDoor
Inherits VMBase
@@ -159,7 +159,7 @@
<Style x:Key="Restart_Button" TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="Height" Value="40"/>
<Setter Property="Width" Value="100"/>
<Setter Property="Width" Value="150"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="FontSize" Value="15"/>
<Setter Property="FontWeight" Value="Regular"/>
@@ -219,30 +219,30 @@ Public Class JsonLuaDoor
End Get
End Property
Private m_DoorStateList As New List(Of IdNameStruct)({New IdNameStruct(0, "Not On Machine"),
New IdNameStruct(1, "Imported"),
New IdNameStruct(2, "On Load"),
New IdNameStruct(3, "On Machine 1"),
New IdNameStruct(4, "On Medium Station"),
New IdNameStruct(6, "On Machine 2"),
New IdNameStruct(7, "On Unload"),
New IdNameStruct(8, "Produced"),
New IdNameStruct(100, "Scrap")})
Public ReadOnly Property DoorStateList As List(Of IdNameStruct)
Get
Return m_DoorStateList
End Get
End Property
'Private m_DoorStateList As New List(Of IdNameStruct)({New IdNameStruct(0, "Not On Machine"),
' New IdNameStruct(1, "Imported"),
' New IdNameStruct(2, "On Load"),
' New IdNameStruct(3, "On Machine 1"),
' New IdNameStruct(4, "On Medium Station"),
' New IdNameStruct(6, "On Machine 2"),
' New IdNameStruct(7, "On Unload"),
' New IdNameStruct(8, "Produced"),
' New IdNameStruct(100, "Scrap")})
'Public ReadOnly Property DoorStateList As List(Of IdNameStruct)
' Get
' Return m_DoorStateList
' End Get
'End Property
Private m_SelDoorState As IdNameStruct
Public Property SelDoorState As IdNameStruct
Get
Return m_SelDoorState
End Get
Set(value As IdNameStruct)
m_SelDoorState = value
End Set
End Property
'Private m_SelDoorState As IdNameStruct
'Public Property SelDoorState As IdNameStruct
' Get
' Return m_SelDoorState
' End Get
' Set(value As IdNameStruct)
' m_SelDoorState = value
' End Set
'End Property
Private m_sDoorCode As String = ""
Public ReadOnly Property sDoorCode As String
@@ -286,72 +286,121 @@ Public Class JsonLuaDoor
End Get
End Property
Private m_nLoadTime As Integer
Public ReadOnly Property nLoadTime As Integer
Get
'Return m_nLoadTime
Return ConvertDateTimeToLuaInteger(m_dtLoadTime)
End Get
End Property
Private m_dtLoadTime As DateTime
<JsonIgnore>
Public ReadOnly Property sLoadTime As String
Get
Return m_dtLoadTime.ToString("yy/MM/dd HH:mm:ss")
End Get
End Property
<JsonIgnore>
Public ReadOnly Property dtLoadTime As DateTime
Get
Return m_dtLoadTime
End Get
End Property
Private m_nMachining1Start As Integer
Public ReadOnly Property nMachining1Start As Integer
Get
Return m_nMachining1Start
End Get
End Property
Private m_dtMachining1Start As DateTime
<JsonIgnore>
Public ReadOnly Property sMachining1Start As String
Get
Return m_dtMachining1Start.ToString("yy/MM/dd HH:mm:ss")
End Get
End Property
<JsonIgnore>
Public ReadOnly Property dtMachining1Start As DateTime
Get
Return m_dtMachining1Start
End Get
End Property
Private m_nMachining1End As Integer
Public ReadOnly Property nMachining1End As Integer
Get
Return m_nMachining1End
End Get
End Property
Private m_dtMachining1End As DateTime
<JsonIgnore>
Public ReadOnly Property sMachining1End As String
Get
Return m_dtMachining1End.ToString("yy/MM/dd HH:mm:ss")
End Get
End Property
<JsonIgnore>
Public ReadOnly Property dtMachining1End As DateTime
Get
Return m_dtMachining1End
End Get
End Property
Private m_nMachining2Start As Integer
Public ReadOnly Property nMachining2Start As Integer
Get
Return m_nMachining2Start
End Get
End Property
Private m_dtMachining2Start As DateTime
<JsonIgnore>
Public ReadOnly Property sMachining2Start As String
Get
Return m_dtMachining2Start.ToString("yy/MM/dd HH:mm:ss")
End Get
End Property
<JsonIgnore>
Public ReadOnly Property dtMachining2Start As DateTime
Get
Return m_dtMachining2Start
End Get
End Property
Private m_nMachining2End As Integer
Public ReadOnly Property nMachining2End As Integer
Get
Return m_nMachining2End
End Get
End Property
Private m_dtMachining2End As DateTime
<JsonIgnore>
Public ReadOnly Property sMachining2End As String
Get
Return m_dtMachining2End.ToString("yy/MM/dd HH:mm:ss")
End Get
End Property
<JsonIgnore>
Public ReadOnly Property dtMachining2End As DateTime
Get
Return m_dtMachining2End
End Get
End Property
Private m_nUnloadTime As Integer
Public ReadOnly Property nUnloadTime As Integer
Get
Return m_nUnloadTime
End Get
End Property
Private m_dtUnloadTime As DateTime
<JsonIgnore>
Public ReadOnly Property sUnloadTime As String
Get
Return m_dtUnloadTime.ToString("yy/MM/dd HH:mm:ss")
End Get
End Property
<JsonIgnore>
Public ReadOnly Property dtUnloadTime As DateTime
Get
Return m_dtUnloadTime