diff --git a/Effector.Plugin.FiveLakes/Constants/ConstIni.vb b/Effector.Plugin.FiveLakes/Constants/ConstIni.vb
index 70bcd17..12153b0 100644
--- a/Effector.Plugin.FiveLakes/Constants/ConstIni.vb
+++ b/Effector.Plugin.FiveLakes/Constants/ConstIni.vb
@@ -16,9 +16,11 @@ Module ConstIni
Public Const S_GENERAL As String = "General"
Public Const K_CAMEXEPATH As String = "CAMExePath"
+ Public Const K_DOORCREATOREXEPATH As String = "DoorCreatorExePath"
Public Const K_BACKUPDIR As String = "BackupDir"
Public Const K_RESOURCESDIR As String = "ResourcesDir"
Public Const K_DDFDIR As String = "DDFDir"
+ Public Const K_DDTDIR As String = "DDTDir"
Public Const K_GENDDFDIR As String = "GenDDFDir"
Public Const K_CSVOUTPUT As String = "CSVOutput"
@@ -28,6 +30,7 @@ Module ConstIni
Public Const K_HEIGHT As String = "Height"
Public Const K_WIDTH As String = "Width"
Public Const K_THICKNESS As String = "Thickness"
+ Public Const K_SWING As String = "Swing"
Public Const K_STATE As String = "State"
Public Const K_PROGRAMSENT As String = "ProgramSent"
Public Const K_PROGRAMSTART As String = "ProgramStart"
diff --git a/Effector.Plugin.FiveLakes/DoorListPage/DoorListPageV.xaml b/Effector.Plugin.FiveLakes/DoorListPage/DoorListPageV.xaml
index 3034b84..74783cd 100644
--- a/Effector.Plugin.FiveLakes/DoorListPage/DoorListPageV.xaml
+++ b/Effector.Plugin.FiveLakes/DoorListPage/DoorListPageV.xaml
@@ -4,6 +4,7 @@
xmlns:local="clr-namespace:Effector.Plugin.FiveLakes">
+
@@ -25,6 +26,7 @@
@@ -37,6 +39,7 @@
@@ -67,30 +70,35 @@
-->
@@ -115,6 +123,7 @@
Visibility="{Binding ExecPercentage_Visibility}"/>
+
+
+
+
+
+
+
+
+
+
+
+
= Door.DoorStates.READY_FOR_PRODUCTION Then
+ If CurrDoor.nState = Door.DoorStates.READY_FOR_PRODUCTION Then
CurrDoor.SetState(Door.DoorStates.VERIFIED, False)
End If
Next
@@ -202,6 +237,10 @@ Public Class DoorListPageVM
End If
End Sub
+ Private Sub WriteCSVTimer_Tick(sender As Object, e As EventArgs)
+ SaveCSV()
+ End Sub
+
Private Sub RefreshGraphicsTimer_Tick(sender As Object, e As EventArgs)
If IsNothing(m_ExecProcessManager) Then Return
' ciclo su coda risultati
@@ -214,7 +253,7 @@ Public Class DoorListPageVM
' elimino file generati
Dim sGenDDFDirPath As String = ""
GetPluginPrivateProfileString(S_GENERAL, K_GENDDFDIR, "", sGenDDFDirPath)
- Dim sDoorFileName As String = CurrRequestDoor.sDDFName & "_" & CurrRequestDoor.nId
+ Dim sDoorFileName As String = Path.GetFileNameWithoutExtension(CurrRequestDoor.sDDFName) & "_" & CurrRequestDoor.nId
Try
File.Delete(sGenDDFDirPath & "\" & sDoorFileName & ".tok")
File.Delete(sGenDDFDirPath & "\" & sDoorFileName & "_2.tok")
@@ -225,22 +264,44 @@ Public Class DoorListPageVM
File.Delete(sGenDDFDirPath & "\" & sDoorFileName & "_2_a.cnc")
File.Delete(sGenDDFDirPath & "\" & sDoorFileName & ".html")
File.Delete(sGenDDFDirPath & "\" & sDoorFileName & "_2.html")
- File.Delete(sGenDDFDirPath & "\" & sDoorFileName & ".log")
- File.Delete(sGenDDFDirPath & "\" & CurrRequestDoor.sDDFName & ".nge")
+ If ArgumentsResult.nResult = 0 Then
+ File.Delete(sGenDDFDirPath & "\" & sDoorFileName & ".log")
+ End If
+ 'File.Delete(sGenDDFDirPath & "\" & CurrRequestDoor.sDDFName & ".nge")
File.Delete(sGenDDFDirPath & "\" & sDoorFileName & ".nge")
File.Delete(sGenDDFDirPath & "\" & sDoorFileName & ".sest")
File.Delete(sGenDDFDirPath & "\" & sDoorFileName & "_2.sest")
- File.Delete(sGenDDFDirPath & "\" & CurrRequestDoor.sDDFName & ".txt")
+ Dim SestFiles() As String = System.IO.Directory.GetFiles(sGenDDFDirPath & "\", sDoorFileName & "*.sest")
+ For Each FilePath In SestFiles
+ File.Delete(FilePath)
+ Next
+ 'File.Delete(sGenDDFDirPath & "\" & CurrRequestDoor.sDDFName & ".txt")
File.Delete(sGenDDFDirPath & "\" & sDoorFileName & ".txt")
File.Delete(sGenDDFDirPath & "\" & sDoorFileName & "_2.txt")
Catch ex As Exception
End Try
End If
+ ' verifico se ci sono altre porte dello stesso tipo da aggiornare
+ If m_AssociationList.ContainsKey(CurrRequestDoor.nId) Then
+ Dim SameDoorList As List(Of Integer) = m_AssociationList(CurrRequestDoor.nId)
+ For Each CurrDoorId In SameDoorList
+ Dim CurrDoor As Door = m_DoorList.FirstOrDefault(Function(x) x.nId = CurrDoorId)
+ If Not IsNothing(CurrDoor) Then
+ CurrDoor.SetState(If(ArgumentsResult.nResult = 0, Door.DoorStates.VERIFIED, Door.DoorStates.VERIFICATION_FAILED))
+ End If
+ Next
+ End If
WriteBackup()
ArgumentsResult = m_ExecProcessManager.ArgumentsResultDequeue
End While
' aggiorno grafica
+ If m_nExecutedArgsCount <> m_ExecProcessManager.nExecutedArgsCounter Then
+ m_nExecutedArgsCount = m_ExecProcessManager.nExecutedArgsCounter
+ m_nExecIncrement = 0
+ ElseIf m_ExecProcessManager.nCalculatingProcesses > 0 Then
+ m_nExecIncrement += 1
+ End If
If Not bExecButton_IsEnabled AndAlso m_ExecProcessManager.ExecutionThreadStatus = ExecProcessManager.ExecutionThreadStatuses.RUNNING Then
NotifyPropertyChanged(NameOf(dExecPercentage))
NotifyPropertyChanged(NameOf(sExecPercentage))
@@ -248,11 +309,6 @@ Public Class DoorListPageVM
If Not bExecButton_IsEnabled AndAlso m_ExecProcessManager.ExecutionThreadStatus = ExecProcessManager.ExecutionThreadStatuses.STOPPED Then
SetExecButtonIsEnabled(True)
End If
- If m_nExecutedArgsCount <> m_ExecProcessManager.nExecutedArgsCounter Then
- m_nExecutedArgsCount = m_ExecProcessManager.nExecutedArgsCounter
- m_nExecIncrement = 0
- End If
- m_nExecIncrement += 1
NotifyPropertyChanged(NameOf(ExecPercentage_Visibility))
End Sub
@@ -313,16 +369,19 @@ Public Class DoorListPageVM
Dim sHeightName As String = ""
Dim sWidthName As String = ""
Dim sThicknessName As String = ""
+ Dim sSwingName As String = ""
GetPluginPrivateProfileString(S_CSV, K_DDFNAME, K_DDFNAME, sDDFName)
GetPluginPrivateProfileString(S_CSV, K_QUANTITY, "", sQuantityName)
GetPluginPrivateProfileString(S_CSV, K_HEIGHT, "", sHeightName)
GetPluginPrivateProfileString(S_CSV, K_WIDTH, "", sWidthName)
GetPluginPrivateProfileString(S_CSV, K_THICKNESS, "", sThicknessName)
+ GetPluginPrivateProfileString(S_CSV, K_SWING, "", sSwingName)
Dim nDDFNameIndex As Integer = Array.IndexOf(Headers, sDDFName)
Dim nQuantityNameIndex As Integer = Array.IndexOf(Headers, sQuantityName)
Dim nHeightNameIndex As Integer = Array.IndexOf(Headers, sHeightName)
Dim nWidthNameIndex As Integer = Array.IndexOf(Headers, sWidthName)
Dim nThicknessNameIndex As Integer = Array.IndexOf(Headers, sThicknessName)
+ Dim nSwingNameIndex As Integer = Array.IndexOf(Headers, sSwingName)
If nDDFNameIndex = -1 Then
Dim sMessage As String = "Error! DDFName column not found! Csv file will not be read!"
' egtoutlog(sMessage)
@@ -365,10 +424,20 @@ Public Class DoorListPageVM
dThickness = 0
End If
End If
+ Dim nSwing As Integer = 0
+ If nSwingNameIndex >= 0 AndAlso nSwingNameIndex < Values.Count Then
+ If Values(nSwingNameIndex).ToUpper = "S" Then
+ nSwing = SWINGTYPE.LEFT
+ Else
+ nSwing = SWINGTYPE.RIGHT
+ End If
+ Else
+ nSwing = SWINGTYPE.UNDEFINED
+ End If
For nQuantityIndex = 1 To nQuantity
Dim nId As Integer = NewDoorId()
- Dim NewDoor As New Door(nId, nLineIndex, Values(nDDFNameIndex), Path.GetFileName(sCSVPath),
- 1, dWidth, dHeight, dThickness, Headers, Values)
+ Dim NewDoor As New Door(nId, nLineIndex, Values(nDDFNameIndex) & ".ddf", Path.GetFileName(sCSVPath),
+ 1, dWidth, dHeight, dThickness, nSwing, Headers, Values)
m_DoorList.Add(NewDoor)
Next
nLineIndex += 1
@@ -382,41 +451,104 @@ Public Class DoorListPageVM
MessageBox.Show("The following lines are not valid and have been skipped:" & sLineErrorList, "Error", MessageBoxButton.OK, MessageBoxImage.Error)
End If
End Using
- Dim sCamExePath As String = ""
- GetPluginPrivateProfileString(S_GENERAL, "CAMExePath", "", sCamExePath)
- Dim sMainLuaPath As String = ""
- GetPluginPrivateProfileString(S_GENERAL, "MainPipeLUA", "", sMainLuaPath)
- Dim bStartExecProcessManager As Boolean = False
- If IsNothing(m_ExecProcessManager) Then
- bStartExecProcessManager = True
- m_ExecProcessManager = New ExecProcessManager(sCamExePath, """" & sMainLuaPath & """")
- AddHandler m_ExecProcessManager.m_AllArgsProcessed, AddressOf ExecProcessManager_AllArgsProcessed
- m_ExecProcessManager.SetMaxCamInstances(3)
- End If
- Dim sDDFDirPath As String = ""
- GetPluginPrivateProfileString(S_GENERAL, K_DDFDIR, "", sDDFDirPath)
- Dim sGenDDFDirPath As String = ""
- GetPluginPrivateProfileString(S_GENERAL, K_GENDDFDIR, "", sGenDDFDirPath)
- For Each Door In m_DoorList
- If Door.nState = Door.DoorStates.LOADED_FROM_CSV Then
- Dim sDDFFilePath As String = sDDFDirPath & "\" & Door.sDDFName & ".ddf"
- Dim sGenDDFFilePath As String = sGenDDFDirPath & "\" & Door.sDDFName & "_" & Door.nId & ".ddf"
- Try
- File.Copy(sDDFFilePath, sGenDDFFilePath, True)
- Catch ex As Exception
- Map.refSupervisorFunction.PlgOutLog("Error: Copy file from " & sDDFFilePath & " to " & sGenDDFFilePath & " failed!")
- End Try
- m_ExecProcessManager.ArgumentsEnqueue(New ProcessArgs(Door.nId, sGenDDFFilePath))
- End If
- Next
- If bStartExecProcessManager OrElse m_ExecProcessManager.ExecutionThreadStatus = ExecProcessManager.ExecutionThreadStatuses.STOPPED Then
- m_ExecProcessManager.StartExecutionThread()
- SetExecButtonIsEnabled(False)
- End If
+ Verify()
+ 'Dim sCamExePath As String = ""
+ 'GetPluginPrivateProfileString(S_GENERAL, "CAMExePath", "", sCamExePath)
+ 'Dim sMainLuaPath As String = ""
+ 'GetPluginPrivateProfileString(S_GENERAL, "MainPipeLUA", "", sMainLuaPath)
+ 'Dim bStartExecProcessManager As Boolean = False
+ 'If IsNothing(m_ExecProcessManager) Then
+ ' bStartExecProcessManager = True
+ ' m_ExecProcessManager = New ExecProcessManager(sCamExePath, """" & sMainLuaPath & """")
+ ' AddHandler m_ExecProcessManager.m_AllArgsProcessed, AddressOf ExecProcessManager_AllArgsProcessed
+ ' m_ExecProcessManager.SetMaxCamInstances(3)
+ 'End If
+ 'Dim sDDFDirPath As String = ""
+ 'GetPluginPrivateProfileString(S_GENERAL, K_DDFDIR, "", sDDFDirPath)
+ 'Dim sGenDDFDirPath As String = ""
+ 'GetPluginPrivateProfileString(S_GENERAL, K_GENDDFDIR, "", sGenDDFDirPath)
+ 'For Each Door In m_DoorList
+ ' If Door.nState = Door.DoorStates.LOADED_FROM_CSV Then
+ ' Dim sDDFFilePath As String = sDDFDirPath & "\" & Door.sDDFName & ".ddf"
+ ' Dim sGenDDFFilePath As String = sGenDDFDirPath & "\" & Door.sDDFName & "_" & Door.nId & ".ddf"
+ ' Try
+ ' File.Copy(sDDFFilePath, sGenDDFFilePath, True)
+ ' Catch ex As Exception
+ ' Map.refSupervisorFunction.PlgOutLog("Error: Copy file from " & sDDFFilePath & " to " & sGenDDFFilePath & " failed!")
+ ' End Try
+ ' m_ExecProcessManager.ArgumentsEnqueue(New ProcessArgs(Door.nId, sGenDDFFilePath))
+ ' End If
+ 'Next
+ 'If bStartExecProcessManager OrElse m_ExecProcessManager.ExecutionThreadStatus = ExecProcessManager.ExecutionThreadStatuses.STOPPED Then
+ ' m_ExecProcessManager.StartExecutionThread()
+ ' SetExecButtonIsEnabled(False)
+ 'End If
End If
WriteBackup()
End Sub
+ Private Function CreateGenDdfFile(nId As Integer, sDDFName As String, dWidth As Double, dHeight As Double, dThickness As Double, nSwing As Integer, ByRef sErrMessage As String) As Boolean
+ ' verifico che ci sia il file ddf
+ Dim sDDTDirPath As String = ""
+ GetPluginPrivateProfileString(S_GENERAL, K_DDTDIR, "", sDDTDirPath)
+ Dim sDDFDirPath As String = ""
+ GetPluginPrivateProfileString(S_GENERAL, K_DDFDIR, "", sDDFDirPath)
+ Dim sGenDDFDirPath As String = ""
+ GetPluginPrivateProfileString(S_GENERAL, K_GENDDFDIR, "", sGenDDFDirPath)
+ Dim sExtension As String = Path.GetExtension(sDDFName)
+ If sExtension.ToLower() = ".ddf" Then
+ Dim sDDFFilePath As String = sDDFDirPath & "\" & sDDFName
+ If Not File.Exists(sDDFFilePath) Then
+ Dim sErr As String = "Il nome inserito (" & sDDFFilePath & ") non corrisponde a nessun file nella cartella dei Ddf (" & sDDFDirPath & ")"
+ Map.refSupervisorFunction.PlgOutLog(sErr)
+ sErrMessage &= "- " & sErr & Environment.NewLine
+ Dim ErrDoor As Door = m_DoorList.FirstOrDefault(Function(x) x.nId = nId)
+ If Not IsNothing(ErrDoor) Then
+ ErrDoor.SetState(DoorStates.VERIFICATION_FAILED)
+ End If
+ NotifyPropertyChanged(NameOf(sDDFName))
+ Return False
+ End If
+ ' copio il ddf nella cartella dei ddf
+ Dim sGenDDFFilePath As String = sGenDDFDirPath & "\" & If(Not String.IsNullOrWhiteSpace(Path.GetDirectoryName(sDDFName)), Path.GetDirectoryName(sDDFName) & "_", "") & Path.GetFileNameWithoutExtension(sDDFName) & "_" & nId & ".ddf"
+ Dim bCopy As Boolean = False
+ Try
+ File.Copy(sDDFFilePath, sGenDDFFilePath, True)
+ bCopy = True
+ Catch ex As Exception
+ Dim sErr As String = "Error: Copy file from " & sDDFFilePath & " to " & sGenDDFFilePath & " failed!"
+ Map.refSupervisorFunction.PlgOutLog(sErr)
+ sErrMessage &= "- " & sErr & Environment.NewLine
+ Dim ErrDoor As Door = m_DoorList.FirstOrDefault(Function(x) x.nId = nId)
+ If Not IsNothing(ErrDoor) Then
+ ErrDoor.SetState(DoorStates.VERIFICATION_FAILED)
+ End If
+ End Try
+ If Not bCopy Then
+ Return False
+ End If
+ ElseIf sExtension.ToLower() = ".ddt" Then
+ ' se file generato
+ If Not Door.CreateDdfFromDdt(nId, sDDFName, dWidth, dHeight, dThickness, nSwing, sErrMessage) Then
+ Dim ErrDoor As Door = m_DoorList.FirstOrDefault(Function(x) x.nId = nId)
+ If Not IsNothing(ErrDoor) Then
+ ErrDoor.SetState(DoorStates.VERIFICATION_FAILED)
+ End If
+ Return False
+ End If
+ Else
+ Dim sErr As String = "Estensione del file non riconosciuta!"
+ Map.refSupervisorFunction.PlgOutLog(sErr)
+ sErrMessage &= "- " & sErr & Environment.NewLine
+ Dim ErrDoor As Door = m_DoorList.FirstOrDefault(Function(x) x.nId = nId)
+ If Not IsNothing(ErrDoor) Then
+ ErrDoor.SetState(DoorStates.VERIFICATION_FAILED)
+ End If
+ Return False
+ End If
+ Return True
+ End Function
+
Public Sub ExecProcessManager_AllArgsProcessed()
m_ExecProcessManager.StopExecutionThread()
End Sub
@@ -466,6 +598,7 @@ Public Class DoorListPageVM
Dim sHeightName As String = ""
Dim sWidthName As String = ""
Dim sThicknessName As String = ""
+ Dim sSwingName As String = ""
Dim sStateName As String = ""
Dim sProgramSentName As String = ""
Dim sProgramStartName As String = ""
@@ -475,15 +608,14 @@ Public Class DoorListPageVM
GetPluginPrivateProfileString(S_CSV, K_HEIGHT, "", sHeightName)
GetPluginPrivateProfileString(S_CSV, K_WIDTH, "", sWidthName)
GetPluginPrivateProfileString(S_CSV, K_THICKNESS, "", sThicknessName)
+ GetPluginPrivateProfileString(S_CSV, K_SWING, "", sSwingName)
GetPluginPrivateProfileString(S_CSV, K_STATE, "", sStateName)
GetPluginPrivateProfileString(S_CSV, K_PROGRAMSENT, "", sProgramSentName)
GetPluginPrivateProfileString(S_CSV, K_PROGRAMSTART, "", sProgramStartName)
GetPluginPrivateProfileString(S_CSV, K_PROGRAMEND, "", sProgramEndName)
' recupero nomi csv presenti
Dim CSVFileList As List(Of String) = DoorList.Select(Function(x) x.sCSVName).Distinct().ToList()
- Dim sCSVName As String = ""
- GetPluginPrivateProfileString(S_CSV, K_MANUALADDEDDOORNAME, "Manual", sCSVName)
- CSVFileList.Remove(sCSVName)
+ CSVFileList.Remove(m_ManualAddedDoorName)
For Each CSVFile In CSVFileList
Dim CSVDoorList As List(Of Door) = (From Door In m_DoorList
Where Door.sCSVName = CSVFile).ToList()
@@ -517,6 +649,11 @@ Public Class DoorListPageVM
If Not IsNothing(ThicknessNameParameter) Then
ThicknessNameParameter.SetValue(DoubleToString(Door.dThickness, 2))
End If
+ Dim SwingNameParameter As CustomerParameter = Door.CustomerParameters.FirstOrDefault(Function(x) x.sHeader = sSwingName)
+ If Not IsNothing(SwingNameParameter) Then
+ SwingNameParameter.SetValue(If(Door.nSwing = SWINGTYPE.LEFT, "S", "D"))
+ End If
+
Dim sDoorRow As String = ""
For Each Parameter In Door.CustomerParameters
' evito di scrivere la quantita'
@@ -669,9 +806,7 @@ Public Class DoorListPageVM
Public Sub AddDoor()
Dim nId As Integer = NewDoorId()
- Dim sCSVName As String = ""
- GetPluginPrivateProfileString(S_CSV, K_MANUALADDEDDOORNAME, "Manual", sCSVName)
- m_DoorList.Add(New Door(nId, 0, "", sCSVName, 1, 0, 0, 0, {}, {}))
+ m_DoorList.Add(New Door(nId, 0, "", m_ManualAddedDoorName, 1, 0, 0, 0, SWINGTYPE.RIGHT, {}, {}))
End Sub
#End Region ' AddDoor
@@ -785,12 +920,10 @@ Public Class DoorListPageVM
End Property
Public Sub Delete()
- Dim sCSVName As String = ""
- GetPluginPrivateProfileString(S_CSV, K_MANUALADDEDDOORNAME, "Manual", sCSVName)
- If m_DoorList.Count = 0 OrElse IsNothing(SelDoor) OrElse String.Compare(SelDoor.sCSVName, sCSVName, True) <> 0 Then Return
+ If m_DoorList.Count = 0 OrElse IsNothing(SelDoor) OrElse String.Compare(SelDoor.sCSVName, m_ManualAddedDoorName, True) <> 0 Then Return
Dim bReset As Boolean = True
If Not LuaGetGlobVar("bReset", bReset) OrElse Not bReset Then
- If (SelDoor.nState >= Door.DoorStates.READY_FOR_PRODUCTION AndAlso SelDoor.nState < Door.DoorStates.MACHINE_1_END) Then Return
+ If (SelDoor.nState >= Door.DoorStates.READY_FOR_PRODUCTION AndAlso SelDoor.nState < Door.DoorStates.MACHINE_2_END) Then Return
End If
If MessageBox.Show("Are you sure you want to delete the selected door?", "Info", MessageBoxButton.YesNo, MessageBoxImage.Information) = MessageBoxResult.Yes Then
m_DoorList.Remove(SelDoor)
@@ -812,15 +945,17 @@ Public Class DoorListPageVM
End Property
Public Sub DeleteAll()
- Dim sCSVName As String = ""
- GetPluginPrivateProfileString(S_CSV, K_MANUALADDEDDOORNAME, "Manual", sCSVName)
- If m_DoorList.Count = 0 OrElse IsNothing(SelDoor) OrElse String.Compare(SelDoor.sCSVName, sCSVName, True) = 0 Then Return
+ If m_DoorList.Count = 0 OrElse IsNothing(SelDoor) OrElse String.Compare(SelDoor.sCSVName, m_ManualAddedDoorName, True) = 0 Then Return
+ Dim bReset As Boolean = True
+ If Not LuaGetGlobVar("bReset", bReset) OrElse Not bReset Then
+ If (SelDoor.nState >= Door.DoorStates.READY_FOR_PRODUCTION AndAlso SelDoor.nState < Door.DoorStates.MACHINE_2_END) Then Return
+ End If
Dim sSelCSVName As String = SelDoor.sCSVName
' verifico che tutte le porte del csv siano in stato prodotto o da non produrre
Dim bAllProduced As Boolean = True
For Each CsvDoor In m_DoorList
If String.Compare(sSelCSVName, CsvDoor.sCSVName, True) = 0 Then
- If CsvDoor.nState <> DoorStates.MACHINE_2_END AndAlso CsvDoor.nState <> DoorStates.PRODUCED AndAlso CsvDoor.nState <> DoorStates.NOTPRODUCE Then
+ If CsvDoor.nState <> DoorStates.MACHINE_2_END AndAlso CsvDoor.nState <> DoorStates.PRODUCED AndAlso CsvDoor.nState <> DoorStates.NOTPRODUCE AndAlso CsvDoor.nState <> DoorStates.VERIFICATION_FAILED Then
bAllProduced = False
End If
End If
@@ -931,6 +1066,9 @@ Public Class DoorListPageVM
End Get
End Property
+ Private m_DifferentDoorList As New List(Of Door)
+ Private m_AssociationList As New Dictionary(Of Integer, List(Of Integer))
+
Public Sub Verify()
Dim sCamExePath As String = ""
GetPluginPrivateProfileString(S_GENERAL, "CAMExePath", "", sCamExePath)
@@ -944,18 +1082,40 @@ Public Class DoorListPageVM
AddHandler m_ExecProcessManager.m_AllArgsProcessed, AddressOf ExecProcessManager_AllArgsProcessed
m_ExecProcessManager.SetMaxCamInstances(3)
End If
- Dim sDDFDirPath As String = ""
- GetPluginPrivateProfileString(S_GENERAL, "DDFDir", "", sDDFDirPath)
+ Dim sGenDDFDirPath As String = ""
+ GetPluginPrivateProfileString(S_GENERAL, K_GENDDFDIR, "", sGenDDFDirPath)
+ Dim sErrMessage As String = ""
+ m_DifferentDoorList.Clear()
+ m_AssociationList.Clear()
For Each Door In m_DoorList
If Door.nState = Door.DoorStates.LOADED_FROM_CSV Or Door.nState = Door.DoorStates.VERIFICATION_FAILED Then
- Dim sDDFFilePath As String = sDDFDirPath & "\" & Door.sDDFName & ".ddf"
- m_ExecProcessManager.ArgumentsEnqueue(New ProcessArgs(Door.nId, sDDFFilePath))
+ ' creo file ddf
+ If CreateGenDdfFile(Door.nId, Door.sDDFName, Door.dWidth, Door.dHeight, Door.dThickness, Door.nSwing, sErrMessage) Then
+ ' verifico se ho gia' lanciato una porta con le stesse caratteristiche
+ Dim DifferentDoor As Door = Nothing
+ If Path.GetExtension(Door.sDDFName).ToLower() = ".ddf" Then
+ DifferentDoor = m_DifferentDoorList.FirstOrDefault(Function(x) Door.sDDFName = x.sDDFName)
+ ElseIf Path.GetExtension(Door.sDDFName).ToLower() = ".ddt" Then
+ DifferentDoor = m_DifferentDoorList.FirstOrDefault(Function(x) Door.sDDFName = x.sDDFName AndAlso Door.dWidth = x.dWidth AndAlso Door.dHeight = x.dHeight AndAlso Door.dThickness = x.dThickness AndAlso Door.nSwing = x.nSwing)
+ End If
+ If Not IsNothing(DifferentDoor) Then
+ m_AssociationList(DifferentDoor.nId).Add(Door.nId)
+ Else
+ m_DifferentDoorList.Add(Door)
+ m_AssociationList.Add(Door.nId, New List(Of Integer))
+ Dim sGenDDFFilePath As String = sGenDDFDirPath & "\" & If(Not String.IsNullOrWhiteSpace(Path.GetDirectoryName(Door.sDDFName)), Path.GetDirectoryName(Door.sDDFName) & "_", "") & Path.GetFileNameWithoutExtension(Door.sDDFName) & "_" & Door.nId & ".ddf"
+ m_ExecProcessManager.ArgumentsEnqueue(New ProcessArgs(Door.nId, sGenDDFFilePath))
+ End If
+ End If
End If
Next
If bStartExecProcessManager OrElse m_ExecProcessManager.ExecutionThreadStatus = ExecProcessManager.ExecutionThreadStatuses.STOPPED Then
m_ExecProcessManager.StartExecutionThread()
SetExecButtonIsEnabled(False)
End If
+ If Not String.IsNullOrWhiteSpace(sErrMessage) Then
+ MessageBox.Show("Impossible creating Ddf files for this doors:" & Environment.NewLine & sErrMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Error)
+ End If
WriteBackup()
End Sub
@@ -968,6 +1128,14 @@ End Class
Public Class Door
Inherits VMBase
+ Public Enum SWINGTYPE As Integer
+ UNDEFINED = 0
+ RIGHT = 1
+ LEFT = 2
+ End Enum
+
+ Private Shared m_refWriteBackup As Action
+
Public Enum DoorStates As Integer
NULL = 0
LOADED_FROM_CSV = 1
@@ -1012,10 +1180,82 @@ Public Class Door
End Property
Private m_sDDFName As String
- Public ReadOnly Property sDDFName As String
+ Public Property sDDFName As String
Get
Return m_sDDFName
End Get
+ Set(value As String)
+ ' verifico che ci sia il file ddf
+ Dim sDDTDirPath As String = ""
+ GetPluginPrivateProfileString(S_GENERAL, K_DDTDIR, "", sDDTDirPath)
+ Dim sDDFDirPath As String = ""
+ GetPluginPrivateProfileString(S_GENERAL, K_DDFDIR, "", sDDFDirPath)
+ Dim sGenDDFDirPath As String = ""
+ GetPluginPrivateProfileString(S_GENERAL, K_GENDDFDIR, "", sGenDDFDirPath)
+ Dim sExtension As String = Path.GetExtension(value)
+ If sExtension.ToLower() = ".ddf" Then
+ Dim sDDFFilePath As String = sDDFDirPath & "\" & value
+ If Not File.Exists(sDDFFilePath) Then
+ MessageBox.Show("Il nome inserito non corrisponde a nessun file nella cartella dei Ddf (" & sDDFDirPath & ") ", "File non trovato!", MessageBoxButton.OK, MessageBoxImage.Error)
+ NotifyPropertyChanged(NameOf(sDDFName))
+ Return
+ End If
+ Me.m_sDDFName = value
+ ' riporto indietro stato a da verificare
+ Me.m_nState = DoorStates.LOADED_FROM_CSV
+ NotifyPropertyChanged(NameOf(nState))
+
+ '' copio il ddf nella cartella dei ddf
+ 'Dim sGenDDFFilePath As String = sGenDDFDirPath & "\" & If(Not String.IsNullOrWhiteSpace(Path.GetDirectoryName(m_sDDFName)), Path.GetDirectoryName(m_sDDFName) & "_", "") & Path.GetFileNameWithoutExtension(m_sDDFName) & "_" & Me.nId & ".ddf"
+ 'Dim bCopy As Boolean = False
+ 'Try
+ ' File.Copy(sDDFFilePath, sGenDDFFilePath, True)
+ ' bCopy = True
+ 'Catch ex As Exception
+ ' Map.refSupervisorFunction.PlgOutLog("Error: Copy file from " & sDDFFilePath & " to " & sGenDDFFilePath & " failed!")
+ 'End Try
+ 'If bCopy Then
+ ' ' riporto indietro stato a da verificare
+ ' Me.m_nState = DoorStates.LOADED_FROM_CSV
+ ' NotifyPropertyChanged(NameOf(nState))
+ 'Else
+ ' NotifyPropertyChanged(NameOf(sDDFName))
+ ' Return
+ 'End If
+ ElseIf sExtension.ToLower() = ".ddt" Then
+ Dim sDDTFilePath As String = sDDTDirPath & "\" & value
+ If Not File.Exists(sDDTFilePath) Then
+ MessageBox.Show("Il nome inserito non corrisponde a nessun file nella cartella dei Ddt (" & sDDTDirPath & ") ", "File non trovato!", MessageBoxButton.OK, MessageBoxImage.Error)
+ NotifyPropertyChanged(NameOf(sDDFName))
+ Return
+ End If
+ m_sDDFName = value
+ ' riporto indietro stato a da verificare
+ Me.m_nState = DoorStates.LOADED_FROM_CSV
+ NotifyPropertyChanged(NameOf(nState))
+ Return
+ 'If m_dWidth = 0 OrElse m_dHeight = 0 OrElse m_dThickness = 0 Then
+ ' m_sDDFName = value
+ ' ' riporto indietro stato a da verificare
+ ' Me.m_nState = DoorStates.LOADED_FROM_CSV
+ ' NotifyPropertyChanged(NameOf(nState))
+ ' Return
+ ' ' se file generato
+ 'ElseIf CreateDdfFromDdt(m_nId, value, m_dWidth, m_dHeight, m_dThickness) Then
+ ' Me.m_sDDFName = value
+ ' ' riporto indietro stato a da verificare
+ ' Me.m_nState = DoorStates.LOADED_FROM_CSV
+ ' NotifyPropertyChanged(NameOf(nState))
+ 'Else
+ ' NotifyPropertyChanged(NameOf(sDDFName))
+ ' Return
+ 'End If
+ Else
+ MessageBox.Show("Estensione del file non riconosciuta!", "Errore!", MessageBoxButton.OK, MessageBoxImage.Error)
+ NotifyPropertyChanged(NameOf(sDDFName))
+ Return
+ End If
+ End Set
End Property
Private m_nQuantity As Integer
@@ -1026,24 +1266,201 @@ Public Class Door
End Property
Private m_dWidth As Double
- Public ReadOnly Property dWidth As Double
+ Public Property dWidth As String
Get
- Return m_dWidth
+ Return DoubleToString(m_dWidth, 2)
End Get
+ Set(value As String)
+ Dim dValue As Double = 0
+ If Not StringToDouble(value, dValue) Then
+ MessageBox.Show("Dimensione non valida!", "Errore!", MessageBoxButton.OK, MessageBoxImage.Error)
+ NotifyPropertyChanged(NameOf(dWidth))
+ Return
+ End If
+ ' verifico se file ddf o ddt
+ Dim sExtension As String = Path.GetExtension(m_sDDFName)
+ If String.IsNullOrWhiteSpace(sExtension) Then
+ Me.m_dWidth = dValue
+ ' riporto indietro stato a da verificare
+ Me.m_nState = DoorStates.LOADED_FROM_CSV
+ NotifyPropertyChanged(NameOf(nState))
+ Return
+ ElseIf sExtension.ToLower() = ".ddf" Then
+ MessageBox.Show("ATTENZIONE! Questa modifica non cambia realmente le dimensioni della porta perchè è selezionato un file ddf!", "Attenzione!", MessageBoxButton.OK, MessageBoxImage.Warning)
+ Me.m_dWidth = dValue
+ Return
+ ElseIf sExtension.ToLower() = ".ddt" Then
+ Me.m_dWidth = dValue
+ ' riporto indietro stato a da verificare
+ Me.m_nState = DoorStates.LOADED_FROM_CSV
+ NotifyPropertyChanged(NameOf(nState))
+ 'If String.IsNullOrWhiteSpace(m_sDDFName) OrElse m_dHeight = 0 OrElse m_dThickness = 0 Then
+ ' m_dWidth = dValue
+ ' ' riporto indietro stato a da verificare
+ ' Me.m_nState = DoorStates.LOADED_FROM_CSV
+ ' NotifyPropertyChanged(NameOf(nState))
+ ' Return
+ 'ElseIf CreateDdfFromDdt(m_nId, m_sDDFName, dValue, m_dHeight, m_dThickness) Then
+ ' m_dWidth = dValue
+ ' ' riporto indietro stato a da verificare
+ ' Me.m_nState = DoorStates.LOADED_FROM_CSV
+ ' NotifyPropertyChanged(NameOf(nState))
+ 'Else
+ ' NotifyPropertyChanged(NameOf(dWidth))
+ ' Return
+ 'End If
+ End If
+ End Set
End Property
Private m_dHeight As Double
- Public ReadOnly Property dHeight As Double
+ Public Property dHeight As String
Get
- Return m_dHeight
+ Return DoubleToString(m_dHeight, 2)
End Get
+ Set(value As String)
+ Dim dValue As Double = 0
+ If Not StringToDouble(value, dValue) Then
+ MessageBox.Show("Dimensione non valida!", "Errore!", MessageBoxButton.OK, MessageBoxImage.Error)
+ NotifyPropertyChanged(NameOf(dHeight))
+ Return
+ End If
+ ' verifico se file ddf o ddt
+ Dim sExtension As String = Path.GetExtension(m_sDDFName)
+ If String.IsNullOrWhiteSpace(sExtension) Then
+ Me.m_dHeight = dValue
+ ' riporto indietro stato a da verificare
+ Me.m_nState = DoorStates.LOADED_FROM_CSV
+ NotifyPropertyChanged(NameOf(nState))
+ Return
+ ElseIf sExtension.ToLower() = ".ddf" Then
+ MessageBox.Show("ATTENZIONE! Questa modifica non cambia realmente le dimensioni della porta perchè è selezionato un file ddf!", "Attenzione!", MessageBoxButton.OK, MessageBoxImage.Warning)
+ Me.m_dHeight = dValue
+ Return
+ ElseIf sExtension.ToLower() = ".ddt" Then
+ Me.m_dHeight = dValue
+ ' riporto indietro stato a da verificare
+ Me.m_nState = DoorStates.LOADED_FROM_CSV
+ NotifyPropertyChanged(NameOf(nState))
+ 'If String.IsNullOrWhiteSpace(m_sDDFName) OrElse m_dWidth = 0 OrElse m_dThickness = 0 Then
+ ' m_dHeight = dValue
+ ' ' riporto indietro stato a da verificare
+ ' Me.m_nState = DoorStates.LOADED_FROM_CSV
+ ' NotifyPropertyChanged(NameOf(nState))
+ ' Return
+ 'ElseIf CreateDdfFromDdt(m_nId, m_sDDFName, m_dWidth, dValue, m_dThickness) Then
+ ' m_dHeight = dValue
+ ' ' riporto indietro stato a da verificare
+ ' Me.m_nState = DoorStates.LOADED_FROM_CSV
+ ' NotifyPropertyChanged(NameOf(nState))
+ 'Else
+ ' NotifyPropertyChanged(NameOf(dHeight))
+ ' Return
+ 'End If
+ End If
+ End Set
End Property
Private m_dThickness As Double
- Public ReadOnly Property dThickness As Double
+ Public Property dThickness As String
Get
- Return m_dThickness
+ Return DoubleToString(m_dThickness, 2)
End Get
+ Set(value As String)
+ Dim dValue As Double = 0
+ If Not StringToDouble(value, dValue) Then
+ MessageBox.Show("Dimensione non valida!", "Errore!", MessageBoxButton.OK, MessageBoxImage.Error)
+ NotifyPropertyChanged(NameOf(dThickness))
+ Return
+ End If
+ ' verifico se file ddf o ddt
+ Dim sExtension As String = Path.GetExtension(m_sDDFName)
+ If String.IsNullOrWhiteSpace(sExtension) Then
+ Me.m_dThickness = dValue
+ ' riporto indietro stato a da verificare
+ Me.m_nState = DoorStates.LOADED_FROM_CSV
+ NotifyPropertyChanged(NameOf(nState))
+ Return
+ ElseIf sExtension.ToLower() = ".ddf" Then
+ MessageBox.Show("ATTENZIONE! Questa modifica non cambia realmente le dimensioni della porta perchè è selezionato un file ddf!", "Attenzione!", MessageBoxButton.OK, MessageBoxImage.Warning)
+ Me.m_dThickness = dValue
+ Return
+ ElseIf sExtension.ToLower() = ".ddt" Then
+ Me.m_dThickness = dValue
+ ' riporto indietro stato a da verificare
+ Me.m_nState = DoorStates.LOADED_FROM_CSV
+ NotifyPropertyChanged(NameOf(nState))
+ 'If String.IsNullOrWhiteSpace(m_sDDFName) OrElse m_dWidth = 0 OrElse m_dHeight = 0 Then
+ ' m_dThickness = dValue
+ ' ' riporto indietro stato a da verificare
+ ' Me.m_nState = DoorStates.LOADED_FROM_CSV
+ ' NotifyPropertyChanged(NameOf(nState))
+ ' Return
+ 'ElseIf CreateDdfFromDdt(m_nId, m_sDDFName, m_dWidth, m_dHeight, dValue) Then
+ ' m_dThickness = dValue
+ ' ' riporto indietro stato a da verificare
+ ' Me.m_nState = DoorStates.LOADED_FROM_CSV
+ ' NotifyPropertyChanged(NameOf(nState))
+ 'Else
+ ' NotifyPropertyChanged(NameOf(dThickness))
+ ' Return
+ 'End If
+ End If
+ End Set
+ End Property
+
+ Private m_SwingList As New List(Of IdNameStruct)({New IdNameStruct(SWINGTYPE.RIGHT, "Destra"), New IdNameStruct(SWINGTYPE.LEFT, "Sinistra")})
+ Public ReadOnly Property SwingList As List(Of IdNameStruct)
+ Get
+ Return m_SwingList
+ End Get
+ End Property
+
+ Private m_nSwing As Integer
+ Public ReadOnly Property nSwing As Integer
+ Get
+ Return m_nSwing
+ End Get
+ End Property
+ Public Property SelSwing As IdNameStruct
+ Get
+ Return m_SwingList.FirstOrDefault(Function(x) x.Id = m_nSwing)
+ End Get
+ Set(value As IdNameStruct)
+ ' verifico se file ddf o ddt
+ Dim sExtension As String = Path.GetExtension(m_sDDFName)
+ If String.IsNullOrWhiteSpace(sExtension) Then
+ Me.m_nSwing = value.Id
+ ' riporto indietro stato a da verificare
+ Me.m_nState = DoorStates.LOADED_FROM_CSV
+ NotifyPropertyChanged(NameOf(nState))
+ Return
+ ElseIf sExtension.ToLower() = ".ddf" Then
+ MessageBox.Show("ATTENZIONE! Questa modifica non cambia realmente lo swing della porta perchè è selezionato un file ddf!", "Attenzione!", MessageBoxButton.OK, MessageBoxImage.Warning)
+ Me.m_nSwing = value.Id
+ Return
+ ElseIf sExtension.ToLower() = ".ddt" Then
+ Me.m_nSwing = value.Id
+ ' riporto indietro stato a da verificare
+ Me.m_nState = DoorStates.LOADED_FROM_CSV
+ NotifyPropertyChanged(NameOf(nState))
+ 'If String.IsNullOrWhiteSpace(m_sDDFName) OrElse m_dWidth = 0 OrElse m_dHeight = 0 Then
+ ' m_dThickness = dValue
+ ' ' riporto indietro stato a da verificare
+ ' Me.m_nState = DoorStates.LOADED_FROM_CSV
+ ' NotifyPropertyChanged(NameOf(nState))
+ ' Return
+ 'ElseIf CreateDdfFromDdt(m_nId, m_sDDFName, m_dWidth, m_dHeight, dValue) Then
+ ' m_dThickness = dValue
+ ' ' riporto indietro stato a da verificare
+ ' Me.m_nState = DoorStates.LOADED_FROM_CSV
+ ' NotifyPropertyChanged(NameOf(nState))
+ 'Else
+ ' NotifyPropertyChanged(NameOf(dThickness))
+ ' Return
+ 'End If
+ End If
+ End Set
End Property
Private m_sCSVName As String
@@ -1229,7 +1646,9 @@ Public Class Door
End Get
End Property
- Sub New(nId As Integer, nCSVLine As Integer, sDDFName As String, sCSVName As String, nQuantity As Integer, dWidth As Double, dHeight As Double, dThickness As Double, HeaderList As String(), ValueList As String())
+#Region "CONSTRUCTOR"
+
+ Sub New(nId As Integer, nCSVLine As Integer, sDDFName As String, sCSVName As String, nQuantity As Integer, dWidth As Double, dHeight As Double, dThickness As Double, nSwing As Integer, HeaderList As String(), ValueList As String())
m_nId = nId
m_nCSVLine = nCSVLine
m_sDDFName = sDDFName
@@ -1238,6 +1657,7 @@ Public Class Door
m_dHeight = dHeight
m_dWidth = dWidth
m_dThickness = dThickness
+ m_nSwing = nSwing
If Not IsNothing(HeaderList) AndAlso HeaderList.Count > 0 AndAlso Not IsNothing(ValueList) AndAlso ValueList.Count > 0 Then
For nParamIndex = 0 To Math.Max(HeaderList.Count, ValueList.Count) - 1
m_CustomerParameters.Add(New CustomerParameter(If(HeaderList.Count > nParamIndex, HeaderList(nParamIndex), ""), If(ValueList.Count > nParamIndex, ValueList(nParamIndex), "")))
@@ -1245,7 +1665,7 @@ Public Class Door
End If
End Sub
- Sub New(nId As Integer, nCSVLine As Integer, sDDFName As String, sCSVName As String, nQuantity As Integer, dWidth As Double, dHeight As Double, dThickness As Double, CustomerParameters As List(Of CustomerParameter))
+ Sub New(nId As Integer, nCSVLine As Integer, sDDFName As String, sCSVName As String, nQuantity As Integer, dWidth As Double, dHeight As Double, dThickness As Double, nSwing As Integer, CustomerParameters As List(Of CustomerParameter))
m_nId = nId
m_nCSVLine = nCSVLine
m_sDDFName = sDDFName
@@ -1254,6 +1674,7 @@ Public Class Door
m_dHeight = dHeight
m_dWidth = dWidth
m_dThickness = dThickness
+ m_nSwing = nSwing
m_CustomerParameters = CustomerParameters
End Sub
@@ -1266,6 +1687,7 @@ Public Class Door
m_dHeight = JsonDoor.dHeight
m_dWidth = JsonDoor.dWidth
m_dThickness = JsonDoor.dThickness
+ m_nSwing = JsonDoor.nSwing
m_nState = JsonDoor.nState
m_CustomerParameters = JsonDoor.CustomerParameters
m_nProdState = JsonDoor.nProdState
@@ -1277,12 +1699,59 @@ Public Class Door
m_dtUnloadTime = JsonDoor.dtUnloadTime
End Sub
+#End Region ' CONSTRUCTOR
+
#Region "METHODS"
Friend Function Copy(nId As Integer) As Door
- Dim sCSVName As String = ""
- GetPluginPrivateProfileString(S_CSV, K_MANUALADDEDDOORNAME, "Manual", sCSVName)
- Return New Door(nId, m_nCSVLine, m_sDDFName, sCSVName, m_nQuantity, m_dWidth, m_dHeight, m_dThickness, m_CustomerParameters)
+ Return New Door(nId, m_nCSVLine, m_sDDFName, Map.refDoorListPageVM.ManualAddedDoorName, m_nQuantity, m_dWidth, m_dHeight, m_dThickness, m_nSwing, m_CustomerParameters)
+ End Function
+
+ Friend Shared Function CreateDdfFromDdt(nId As Integer, sDDFName As String, dWidth As Double, dHeight As Double, dThickness As Double, nSwing As Integer, ByRef sErrMessage As String) As Boolean
+ Dim sDoorCreatorExePath As String = ""
+ GetPluginPrivateProfileString(S_GENERAL, K_DOORCREATOREXEPATH, "", sDoorCreatorExePath)
+ Dim sDDTDirPath As String = ""
+ GetPluginPrivateProfileString(S_GENERAL, K_DDTDIR, "", sDDTDirPath)
+ Dim sGenDDFDirPath As String = ""
+ GetPluginPrivateProfileString(S_GENERAL, K_GENDDFDIR, "", sGenDDFDirPath)
+ Dim sDDTFilePath As String = sDDTDirPath & "\" & sDDFName
+ If String.IsNullOrWhiteSpace(sDoorCreatorExePath) OrElse Not File.Exists(sDoorCreatorExePath) Then
+ MessageBox.Show("Path del programma di calcolo del ddf mancante o errata!", "Errore!", MessageBoxButton.OK, MessageBoxImage.Error)
+ Return False
+ ElseIf Not File.Exists(sDDTFilePath) Then
+ Dim sErr As String = "File non trovato! Il nome inserito non corrisponde a nessun file nella cartella dei Ddt (" & sDDTDirPath & ")"
+ Map.refSupervisorFunction.PlgOutLog(sErr)
+ sErrMessage &= "- " & sErr & Environment.NewLine
+ Return False
+ End If
+ ' creo il ddf
+ Dim sGenDDFFilePath As String = sGenDDFDirPath & "\" & If(Not String.IsNullOrWhiteSpace(Path.GetDirectoryName(sDDFName)), Path.GetDirectoryName(sDDFName) & "_", "") & Path.GetFileNameWithoutExtension(sDDFName) & "_" & nId & ".ddf"
+ Dim Proc As New Process()
+ Proc.StartInfo.FileName = """" & sDoorCreatorExePath & """"
+ Proc.StartInfo.RedirectStandardInput = False
+ Proc.StartInfo.RedirectStandardOutput = False
+ Proc.StartInfo.Arguments = """" & sDDTFilePath & ";" & DoubleToString(dWidth, 2) & ";" & DoubleToString(dHeight, 2) & ";" & DoubleToString(dThickness, 2) & ";" & sGenDDFFilePath & ";" & If(nSwing = SWINGTYPE.LEFT, "L", "R") & """"
+ Proc.StartInfo.UseShellExecute = False
+ Proc.StartInfo.CreateNoWindow = True
+ Dim ExecCounter = 0
+ If Proc.Start Then
+ While Not Proc.HasExited
+ If ExecCounter >= 30 Then
+ Proc.Kill()
+ Exit While
+ End If
+ Threading.Thread.Sleep(100)
+ ExecCounter += 1
+ End While
+ End If
+ ' se file generato
+ If Not File.Exists(sGenDDFFilePath) Then
+ Dim sErr As String = "Errore! Generazione file ddf fallita! (" & sDDTDirPath & ")"
+ Map.refSupervisorFunction.PlgOutLog(sErr)
+ sErrMessage &= "- " & sErr & Environment.NewLine
+ Return False
+ End If
+ Return True
End Function
#End Region ' METHODS
@@ -1348,4 +1817,18 @@ Public Class StateToSelColorConverter
Throw New NotImplementedException()
End Function
+End Class
+
+Public Class DDTListToBooleanConverter
+ Implements IValueConverter
+
+ Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.Convert
+ If Not TypeOf value Is ObservableCollection(Of String) Then Return False
+ Return DirectCast(value, ObservableCollection(Of String)).Count = 0
+ End Function
+
+ Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
+ Throw New NotImplementedException()
+ End Function
+
End Class
\ No newline at end of file
diff --git a/Effector.Plugin.FiveLakes/DoorListPage/DoorListPageVM.vb.bak b/Effector.Plugin.FiveLakes/DoorListPage/DoorListPageVM.vb.bak
deleted file mode 100644
index 2e27f60..0000000
--- a/Effector.Plugin.FiveLakes/DoorListPage/DoorListPageVM.vb.bak
+++ /dev/null
@@ -1,977 +0,0 @@
-Imports System.Collections.ObjectModel
-Imports System.IO
-Imports Newtonsoft.Json
-Imports System.Windows.Threading
-Imports System.Text.RegularExpressions
-Imports Effector.Plugin.FiveLakes.Door
-Imports System.Globalization
-
-Public Class DoorListPageVM
- Inherits VMBase
-
- Private m_BackupTimer As New DispatcherTimer
- Private m_RefreshGraphicsTimer As New DispatcherTimer
- Private m_ExecProcessManager As ExecProcessManager
-
- Private m_DoorList As New ObservableCollection(Of Door)
- Public ReadOnly Property DoorList As ObservableCollection(Of Door)
- Get
- Return m_DoorList
- End Get
- End Property
- Private m_SelDoor As Door
- Public Property SelDoor As Door
- Get
- Return m_SelDoor
- End Get
- Set(value As Door)
- m_SelDoor = value
- End Set
- End Property
-
- Private m_bExecButton_IsEnabled As Boolean = True
- Public ReadOnly Property bExecButton_IsEnabled As Boolean
- Get
- Return m_bExecButton_IsEnabled
- End Get
- End Property
- Private Sub SetExecButtonIsEnabled(bValue As Boolean)
- m_bExecButton_IsEnabled = bValue
- NotifyPropertyChanged(NameOf(bExecButton_IsEnabled))
- End Sub
- Private m_nModifyIndex As Integer = 0
- Private m_nBackupindex As Integer = 0
- Private m_bWritingBackup As Boolean = False
-
- ' Definizione comandi
- Private m_cmdOpenCSV As ICommand
- Private m_cmdSkipDoor As ICommand
- Private m_cmdMoveUp As ICommand
- Private m_cmdMoveDown As ICommand
- Private m_cmdDelete As ICommand
- Private m_cmdDeleteAll As ICommand
- Private m_cmdProduce As ICommand
- Private m_cmdProduceAll As ICommand
- Private m_cmdResetProductionQueue As ICommand
- Private m_cmdVerify As ICommand
-
-#Region "CONSTRUCTOR"
-
- Sub New()
- ' imposto riferimento in Map
- Map.SetRefDoorListPageVM(Me)
- Dim sBackupDirPath As String = ""
- GetPluginPrivateProfileString(S_GENERAL, "BackupDir", "", sBackupDirPath)
- Dim sBackupFilePath As String = sBackupDirPath & "\Backup.json"
- Read(sBackupFilePath)
- m_BackupTimer.Interval = New TimeSpan(0, 0, 1)
- AddHandler m_BackupTimer.Tick, AddressOf BackupTimer_Tick
- m_RefreshGraphicsTimer.Interval = New TimeSpan(0, 0, 1)
- AddHandler m_RefreshGraphicsTimer.Tick, AddressOf RefreshGraphicsTimer_Tick
- m_BackupTimer.Start()
- m_RefreshGraphicsTimer.Start()
- End Sub
-#End Region ' CONSTRUCTOR
-
-#Region "METHODS"
-
- Friend Function ExecCAMProcess(sDDFName As String) As Boolean
- ' lancio esecuzione programma
- Dim sCamExePath As String = ""
- GetPluginPrivateProfileString(S_GENERAL, "CAMExePath", "", sCamExePath)
- Dim sMainLuaPath As String = ""
- GetPluginPrivateProfileString(S_GENERAL, "MainLUA", "", sMainLuaPath)
- Dim sGenDDFDirPath As String = ""
- GetPluginPrivateProfileString(S_GENERAL, K_GENDDFDIR, "", sGenDDFDirPath)
- Dim sDDFFilePath As String = sGenDDFDirPath & "\" & sDDFName
- Return Map.refSupervisorFunction.PlgExecProcess(sCamExePath, sMainLuaPath, sDDFFilePath)
- End Function
-
- Friend Function ExecCAMProcessAsync(sDDFName As String) As Boolean
- ' lancio esecuzione programma
- Dim sCamExePath As String = ""
- GetPluginPrivateProfileString(S_GENERAL, "CAMExePath", "", sCamExePath)
- Dim sMainLuaPath As String = ""
- GetPluginPrivateProfileString(S_GENERAL, "MainLUA", "", sMainLuaPath)
- Dim sGenDDFDirPath As String = ""
- GetPluginPrivateProfileString(S_GENERAL, K_GENDDFDIR, "", sGenDDFDirPath)
- Dim sDDFFilePath As String = sGenDDFDirPath & "\" & sDDFName
- Return Map.refSupervisorFunction.PlgExecProcessAsync(sCamExePath, sMainLuaPath, sDDFFilePath)
- End Function
-
- Public Sub Read(FilePath As String)
- If Not File.Exists(FilePath) Then Return
- Dim sReadedFile As String = File.ReadAllText(FilePath)
- Dim JsonDoorList As List(Of JsonDoor) = JsonConvert.DeserializeObject(Of List(Of JsonDoor))(sReadedFile)
- JsonDoorList = JsonDoorList.OrderBy(Of Integer)(Function(x) x.nListIndex).ToList()
-
- m_DoorList = New ObservableCollection(Of Door)((From JsonDoor In JsonDoorList
- Select New Door(JsonDoor)).ToList())
- End Sub
-
- Public Sub Write(FilePath As String)
- Dim JsonDoorList As New List(Of JsonDoor)
- For nDoorIndex As Integer = 0 To m_DoorList.Count - 1
- JsonDoorList.Add(New JsonDoor(nDoorIndex + 1, m_DoorList(nDoorIndex)))
- Next
- Dim JsonFromWindow As String = JsonConvert.SerializeObject(JsonDoorList, Formatting.Indented)
- If File.Exists(FilePath) Then
- Dim sBackupFilePath As String = Path.ChangeExtension(FilePath, ".bck")
- If File.Exists(sBackupFilePath) Then
- Try
- File.Delete(sBackupFilePath)
- Catch ex As Exception
- Map.refSupervisorFunction.PlgOutLog("Error! Impossible deleting backup file!")
- End Try
- End If
- Try
- File.Move(FilePath, sBackupFilePath)
- Catch ex As Exception
- Map.refSupervisorFunction.PlgOutLog("Error! Impossible renaming backup file!")
- End Try
- End If
- File.WriteAllText(FilePath, JsonFromWindow)
- End Sub
-
- Private Sub WriteBackupCmd()
- If m_bWritingBackup Then Return
- m_bWritingBackup = True
- m_nBackupindex = m_nModifyIndex
- Dim sBackupDirPath As String = ""
- GetPluginPrivateProfileString(S_GENERAL, K_BACKUPDIR, "", sBackupDirPath)
- Dim sBackupFilePath As String = sBackupDirPath & "\Backup.json"
- Write(sBackupFilePath)
- m_bWritingBackup = False
- End Sub
-
- Friend Sub WriteBackup()
- m_nModifyIndex += 1
- End Sub
-
- Private Sub BackupTimer_Tick(sender As Object, e As EventArgs)
- If m_nBackupindex < m_nModifyIndex Then
- WriteBackupCmd()
- End If
- End Sub
-
- Private Sub RefreshGraphicsTimer_Tick(sender As Object, e As EventArgs)
- If IsNothing(m_ExecProcessManager) Then Return
- ' ciclo su coda risultati
- Dim ArgumentsResult As ProcessArgsResult = m_ExecProcessManager.ArgumentsResultDequeue
- While Not IsNothing(ArgumentsResult)
- ' aggiorno risultato sulla porta
- Dim CurrRequestDoor As Door = m_DoorList.FirstOrDefault(Function(x) x.nId = ArgumentsResult.ProcessArgs.nId)
- If Not IsNothing(CurrRequestDoor) Then
- CurrRequestDoor.SetState(If(ArgumentsResult.nResult = 0, Door.DoorStates.VERIFIED, Door.DoorStates.VERIFICATION_FAILED))
- ' elimino file generati
- Dim sGenDDFDirPath As String = ""
- GetPluginPrivateProfileString(S_GENERAL, K_GENDDFDIR, "", sGenDDFDirPath)
- Dim sDoorFileName As String = CurrRequestDoor.sDDFName & "_" & CurrRequestDoor.nId
- Try
- File.Delete(sGenDDFDirPath & "\" & sDoorFileName & ".tok")
- File.Delete(sGenDDFDirPath & "\" & sDoorFileName & "_2.tok")
- File.Delete(sGenDDFDirPath & "\" & sDoorFileName & ".cnc")
- File.Delete(sGenDDFDirPath & "\" & sDoorFileName & "_a.cnc")
- File.Delete(sGenDDFDirPath & "\" & sDoorFileName & "_b.cnc")
- File.Delete(sGenDDFDirPath & "\" & sDoorFileName & "_2.cnc")
- File.Delete(sGenDDFDirPath & "\" & sDoorFileName & "_2_a.cnc")
- File.Delete(sGenDDFDirPath & "\" & sDoorFileName & ".html")
- File.Delete(sGenDDFDirPath & "\" & sDoorFileName & "_2.html")
- File.Delete(sGenDDFDirPath & "\" & sDoorFileName & ".log")
- File.Delete(sGenDDFDirPath & "\" & CurrRequestDoor.sDDFName & ".nge")
- File.Delete(sGenDDFDirPath & "\" & sDoorFileName & ".nge")
- File.Delete(sGenDDFDirPath & "\" & sDoorFileName & ".sest")
- File.Delete(sGenDDFDirPath & "\" & sDoorFileName & "_2.sest")
- File.Delete(sGenDDFDirPath & "\" & CurrRequestDoor.sDDFName & ".txt")
- File.Delete(sGenDDFDirPath & "\" & sDoorFileName & ".txt")
- File.Delete(sGenDDFDirPath & "\" & sDoorFileName & "_2.txt")
- Catch ex As Exception
-
- End Try
- End If
- WriteBackup()
- ArgumentsResult = m_ExecProcessManager.ArgumentsResultDequeue
- End While
- If Not bExecButton_IsEnabled AndAlso m_ExecProcessManager.ExecutionThreadStatus = ExecProcessManager.ExecutionThreadStatuses.STOPPED Then
- SetExecButtonIsEnabled(True)
- End If
- End Sub
-
- Friend Function GetNextDoor() As Door
- Dim NextDoor As Door = m_DoorList.FirstOrDefault(Function(x) x.nState = Door.DoorStates.READY_FOR_PRODUCTION)
- If Not IsNothing(NextDoor) Then
- Map.refSupervisorFunction.PlgOutLog("GetNextDoor: door " & NextDoor.nId & " set at ON_LOAD_STATION")
- NextDoor.SetState(Door.DoorStates.ON_LOAD_STATION)
- WriteBackup()
- End If
- Return NextDoor
- End Function
-
- Public Sub ResetProductionQueue()
- For Each Door In m_DoorList
- If Door.nState = Door.DoorStates.READY_FOR_PRODUCTION Then
- Door.SetState(Door.DoorStates.VERIFIED, False)
- End If
- Next
- End Sub
-
-#End Region ' METHODS
-
-#Region "COMMANDS"
-
-#Region "OpenCSV"
-
- Public ReadOnly Property OpenCSV_Command As ICommand
- Get
- If m_cmdOpenCSV Is Nothing Then
- m_cmdOpenCSV = New Command(AddressOf OpenCSV)
- End If
- Return m_cmdOpenCSV
- End Get
- End Property
-
- Public Sub OpenCSV()
- 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 sCSVPath As String = OpenFileDialog.FileName
- Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(sCSVPath)
- 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 sDDFName As String = ""
- Dim sQuantityName As String = ""
- Dim sHeightName As String = ""
- Dim sWidthName As String = ""
- Dim sThicknessName As String = ""
- GetPluginPrivateProfileString(S_CSV, K_DDFNAME, K_DDFNAME, sDDFName)
- GetPluginPrivateProfileString(S_CSV, K_QUANTITY, "", sQuantityName)
- GetPluginPrivateProfileString(S_CSV, K_HEIGHT, "", sHeightName)
- GetPluginPrivateProfileString(S_CSV, K_WIDTH, "", sWidthName)
- GetPluginPrivateProfileString(S_CSV, K_THICKNESS, "", sThicknessName)
- Dim nDDFNameIndex As Integer = Array.IndexOf(Headers, sDDFName)
- Dim nQuantityNameIndex As Integer = Array.IndexOf(Headers, sQuantityName)
- Dim nHeightNameIndex As Integer = Array.IndexOf(Headers, sHeightName)
- Dim nWidthNameIndex As Integer = Array.IndexOf(Headers, sWidthName)
- Dim nThicknessNameIndex As Integer = Array.IndexOf(Headers, sThicknessName)
- If nDDFNameIndex = -1 Then
- Dim sMessage As String = "Error! DDFName column 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 nLineIndex As Integer = 1
- Dim sLineErrorList As String = ""
- While Not MyReader.EndOfData
- Try
- Values = MyReader.ReadFields()
- Dim nQuantity As Integer = 1
- If nQuantityNameIndex >= 0 AndAlso nQuantityNameIndex < Values.Count Then
- If Not Integer.TryParse(Values(nQuantityNameIndex), nQuantity) OrElse nQuantity < 1 Then
- nQuantity = 1
- Dim sLine As String = ""
- For nValueIndex = 0 To Values.Count - 1
- sLine &= Values(nValueIndex) & If(nValueIndex < Values.Count, ";", "")
- Next
- sLineErrorList &= "Quantity not readable in line " & sLine & ". This line will be skipped"
- Continue While
- End If
- End If
- Dim dWidth As Double = 0
- If nWidthNameIndex >= 0 AndAlso nWidthNameIndex < Values.Count Then
- If Not StringToDouble(Values(nWidthNameIndex), dWidth) OrElse dWidth < 0 Then
- dWidth = 0
- End If
- End If
- Dim dHeight As Double = 0
- If nHeightNameIndex >= 0 AndAlso nHeightNameIndex < Values.Count Then
- If Not StringToDouble(Values(nHeightNameIndex), dHeight) OrElse dHeight < 0 Then
- dHeight = 0
- End If
- End If
- Dim dThickness As Double = 0
- If nThicknessNameIndex >= 0 AndAlso nThicknessNameIndex < Values.Count Then
- If Not StringToDouble(Values(nThicknessNameIndex), dThickness) OrElse dThickness < 0 Then
- dThickness = 0
- End If
- End If
- For nQuantityIndex = 1 To nQuantity
- Dim nId As Integer = 1
- If m_DoorList.Count > 0 Then
- Dim nMaxId As Integer = m_DoorList.Max(Of Integer)(Function(x) x.nId)
- 'If nMaxId < 100 Then
- nId = nMaxId + 1
- 'End If
- End If
- Dim NewDoor As New Door(nId, nLineIndex, Values(nDDFNameIndex), Path.GetFileName(sCSVPath),
- 1, dWidth, dHeight, dThickness, Headers, Values)
- m_DoorList.Add(NewDoor)
- Next
- nLineIndex += 1
- 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
- Dim sCamExePath As String = ""
- GetPluginPrivateProfileString(S_GENERAL, "CAMExePath", "", sCamExePath)
- Dim sMainLuaPath As String = ""
- GetPluginPrivateProfileString(S_GENERAL, "MainPipeLUA", "", sMainLuaPath)
- Dim bStartExecProcessManager As Boolean = False
- If IsNothing(m_ExecProcessManager) Then
- bStartExecProcessManager = True
- m_ExecProcessManager = New ExecProcessManager(sCamExePath, """" & sMainLuaPath & """")
- AddHandler m_ExecProcessManager.m_AllArgsProcessed, AddressOf ExecProcessManager_AllArgsProcessed
- m_ExecProcessManager.SetMaxCamInstances(3)
- End If
- Dim sDDFDirPath As String = ""
- GetPluginPrivateProfileString(S_GENERAL, K_DDFDIR, "", sDDFDirPath)
- Dim sGenDDFDirPath As String = ""
- GetPluginPrivateProfileString(S_GENERAL, K_GENDDFDIR, "", sGenDDFDirPath)
- For Each Door In m_DoorList
- If Door.nState = Door.DoorStates.LOADED_FROM_CSV Then
- Dim sDDFFilePath As String = sDDFDirPath & "\" & Door.sDDFName & ".ddf"
- Dim sGenDDFFilePath As String = sGenDDFDirPath & "\" & Door.sDDFName & "_" & Door.nId & ".ddf"
- Try
- File.Copy(sDDFFilePath, sGenDDFFilePath, True)
- Catch ex As Exception
- Map.refSupervisorFunction.PlgOutLog("Error: Copy file from " & sDDFFilePath & " to " & sGenDDFFilePath & " failed!")
- End Try
- m_ExecProcessManager.ArgumentsEnqueue(New ProcessArgs(Door.nId, sGenDDFFilePath))
- End If
- Next
- If bStartExecProcessManager OrElse m_ExecProcessManager.ExecutionThreadStatus = ExecProcessManager.ExecutionThreadStatuses.STOPPED Then
- m_ExecProcessManager.StartExecutionThread()
- SetExecButtonIsEnabled(False)
- End If
- End If
- WriteBackup()
- End Sub
-
- Public Sub ExecProcessManager_AllArgsProcessed()
- m_ExecProcessManager.StopExecutionThread()
- End Sub
-
- Public Sub ExecProcessManager_PostProcess(ProcessArgsResult As ProcessArgsResult)
- ' verifico file di risultati
- Dim sDDFDirPath As String = ""
- GetPluginPrivateProfileString(S_GENERAL, "DDFDir", "", sDDFDirPath)
- Dim sDDFFilePath As String = sDDFDirPath & "\" & ProcessArgsResult.ProcessArgs.sArgs
- Dim sTxtFilePath As String = Path.ChangeExtension(sDDFDirPath, ".txt")
- If Not File.Exists(sTxtFilePath) Then
- ProcessArgsResult.SetResult(-1)
- Return
- End If
- Dim TxtFileLines As String() = File.ReadAllLines(sTxtFilePath)
- For nLineIndex As Integer = 0 To TxtFileLines.Count - 1
- Dim Match As Match = Regex.Match(TxtFileLines(nLineIndex), "\s*Err\s*=\s*(\d*)\s*")
- If Not IsNothing(Match) AndAlso Not IsNothing(Match.Groups(1)) Then
- Dim sResult As String = Match.Groups(1).Value
- Dim nResult As Integer = -2
- If Integer.TryParse(sResult, nResult) Then
- ProcessArgsResult.SetResult(nResult)
- Else
- ProcessArgsResult.SetResult(-2)
- End If
- End If
- Next
- End Sub
-
-#End Region ' OpenCSV
-
-#Region "SkipDoor"
-
- Public ReadOnly Property SkipDoor_Command As ICommand
- Get
- If m_cmdSkipDoor Is Nothing Then
- m_cmdSkipDoor = New Command(AddressOf SkipDoor)
- End If
- Return m_cmdSkipDoor
- End Get
- End Property
-
- Public Sub SkipDoor()
- If IsNothing(SelDoor) OrElse (SelDoor.nState <> Door.DoorStates.VERIFIED AndAlso SelDoor.nState <> Door.DoorStates.SKIPPED) Then Return
- SelDoor.SetState(If(SelDoor.nState = Door.DoorStates.VERIFIED, Door.DoorStates.SKIPPED, Door.DoorStates.VERIFIED))
- WriteBackup()
- End Sub
-
-#End Region ' SkipDoor
-
-#Region "MoveUp"
-
- Public ReadOnly Property MoveUp_Command As ICommand
- Get
- If m_cmdMoveUp Is Nothing Then
- m_cmdMoveUp = New Command(AddressOf MoveUp)
- End If
- Return m_cmdMoveUp
- End Get
- End Property
-
- Public Sub MoveUp()
- If IsNothing(SelDoor) Then Return
- Dim nOldIndex As Integer = m_DoorList.IndexOf(SelDoor)
- If nOldIndex = 0 Then Return
- If m_DoorList(nOldIndex - 1).nState >= Door.DoorStates.READY_FOR_PRODUCTION Then Return
- m_DoorList.Move(nOldIndex, nOldIndex - 1)
- WriteBackup()
- End Sub
-
-#End Region ' MoveUp
-
-#Region "MoveDown"
-
- Public ReadOnly Property MoveDown_Command As ICommand
- Get
- If m_cmdMoveDown Is Nothing Then
- m_cmdMoveDown = New Command(AddressOf MoveDown)
- End If
- Return m_cmdMoveDown
- End Get
- End Property
-
- Public Sub MoveDown()
- If IsNothing(SelDoor) OrElse SelDoor.nState >= Door.DoorStates.READY_FOR_PRODUCTION Then Return
- Dim nOldIndex As Integer = m_DoorList.IndexOf(SelDoor)
- If nOldIndex = m_DoorList.Count - 1 Then Return
- m_DoorList.Move(nOldIndex, nOldIndex + 1)
- WriteBackup()
- End Sub
-
-#End Region ' MoveDown
-
-#Region "Delete"
-
- Public ReadOnly Property Delete_Command As ICommand
- Get
- If m_cmdDelete Is Nothing Then
- m_cmdDelete = New Command(AddressOf Delete)
- End If
- Return m_cmdDelete
- End Get
- End Property
-
- Public Sub Delete()
- If IsNothing(SelDoor) OrElse SelDoor.nState >= Door.DoorStates.READY_FOR_PRODUCTION Then Return
- If MessageBox.Show("Are you sure you want to delete the selected door?", "Info", MessageBoxButton.YesNo, MessageBoxImage.Information) = MessageBoxResult.Yes Then
- m_DoorList.Remove(SelDoor)
- WriteBackup()
- End If
- End Sub
-
-#End Region ' Delete
-
-#Region "DeleteAll"
-
- Public ReadOnly Property DeleteAll_Command As ICommand
- Get
- If m_cmdDeleteAll Is Nothing Then
- m_cmdDeleteAll = New Command(AddressOf DeleteAll)
- End If
- Return m_cmdDeleteAll
- End Get
- End Property
-
- Public Sub DeleteAll()
- If m_DoorList.Count = 0 Then Return
- If MessageBox.Show("Are you sure you want to delete all the doors?", "Info", MessageBoxButton.YesNo, MessageBoxImage.Information) = MessageBoxResult.Yes Then
- For nDoorIndex = m_DoorList.Count - 1 To 0 Step -1
- Dim Door As Door = m_DoorList(nDoorIndex)
- If Door.nState >= Door.DoorStates.READY_FOR_PRODUCTION Then Continue For
- m_DoorList.Remove(Door)
- Next
- WriteBackup()
- End If
- End Sub
-
-#End Region ' DeleteAll
-
-#Region "Produce"
-
- Public ReadOnly Property Produce_Command As ICommand
- Get
- If m_cmdProduce Is Nothing Then
- m_cmdProduce = New Command(AddressOf Produce)
- End If
- Return m_cmdProduce
- End Get
- End Property
-
- Public Sub Produce()
- ProduceDoor(m_SelDoor)
- WriteBackup()
- End Sub
-
- Public Sub ProduceDoor(DoorToProduce As Door, Optional bWriteBackup As Boolean = True)
- If IsNothing(DoorToProduce) OrElse DoorToProduce.nState = Door.DoorStates.SKIPPED OrElse
- DoorToProduce.nState = Door.DoorStates.VERIFICATION_FAILED OrElse
- DoorToProduce.nState >= Door.DoorStates.READY_FOR_PRODUCTION Then Return
- ' la sposto dopo l'ultima da produrre
- Dim nNewIndex As Integer = m_DoorList.IndexOf(m_DoorList.FirstOrDefault(Function(x) x.nState < Door.DoorStates.READY_FOR_PRODUCTION))
- Dim nOldIndex As Integer = m_DoorList.IndexOf(DoorToProduce)
- m_DoorList.Move(nOldIndex, nNewIndex)
- DoorToProduce.SetState(Door.DoorStates.READY_FOR_PRODUCTION, bWriteBackup)
- End Sub
-
-#End Region ' Produce
-
-#Region "ProduceAll"
-
- Public ReadOnly Property ProduceAll_Command As ICommand
- Get
- If m_cmdProduceAll Is Nothing Then
- m_cmdProduceAll = New Command(AddressOf ProduceAll)
- End If
- Return m_cmdProduceAll
- End Get
- End Property
-
- Public Sub ProduceAll()
- If m_DoorList.Count = 0 Then Return
- For nDoorIndex = 0 To m_DoorList.Count - 1
- Dim CurrDoor As Door = m_DoorList(nDoorIndex)
- ProduceDoor(CurrDoor, False)
- Next
- WriteBackup()
- End Sub
-
-#End Region ' ProduceAll
-
-#Region "ResetProductionQueue"
-
- Public ReadOnly Property ResetProductionQueue_Command As ICommand
- Get
- If m_cmdResetProductionQueue Is Nothing Then
- m_cmdResetProductionQueue = New Command(AddressOf ResetProductionQueueCmd)
- End If
- Return m_cmdResetProductionQueue
- End Get
- End Property
-
- Public Sub ResetProductionQueueCmd()
- ResetProductionQueue()
- WriteBackup()
- End Sub
-
-#End Region ' ResetProductionQueue
-
-#Region "Verify"
-
- Public ReadOnly Property Verify_Command As ICommand
- Get
- If m_cmdVerify Is Nothing Then
- m_cmdVerify = New Command(AddressOf Verify)
- End If
- Return m_cmdVerify
- End Get
- End Property
-
- Public Sub Verify()
- Dim sCamExePath As String = ""
- GetPluginPrivateProfileString(S_GENERAL, "CAMExePath", "", sCamExePath)
- Dim sMainLuaPath As String = ""
- GetPluginPrivateProfileString(S_GENERAL, "MainPipeLUA", "", sMainLuaPath)
- Dim bStartExecProcessManager As Boolean = False
- If IsNothing(m_ExecProcessManager) Then
- bStartExecProcessManager = True
- m_ExecProcessManager = New ExecProcessManager(sCamExePath, """" & sMainLuaPath & """")
- 'm_ExecProcessManager.SetPostProcess(AddressOf ExecProcessManager_PostProcess)
- AddHandler m_ExecProcessManager.m_AllArgsProcessed, AddressOf ExecProcessManager_AllArgsProcessed
- m_ExecProcessManager.SetMaxCamInstances(3)
- End If
- Dim sDDFDirPath As String = ""
- GetPluginPrivateProfileString(S_GENERAL, "DDFDir", "", sDDFDirPath)
- For Each Door In m_DoorList
- If Door.nState = Door.DoorStates.LOADED_FROM_CSV Or Door.nState = Door.DoorStates.VERIFICATION_FAILED Then
- Dim sDDFFilePath As String = sDDFDirPath & "\" & Door.sDDFName & ".ddf"
- m_ExecProcessManager.ArgumentsEnqueue(New ProcessArgs(Door.nId, sDDFFilePath))
- End If
- Next
- If bStartExecProcessManager OrElse m_ExecProcessManager.ExecutionThreadStatus = ExecProcessManager.ExecutionThreadStatuses.STOPPED Then
- m_ExecProcessManager.StartExecutionThread()
- SetExecButtonIsEnabled(False)
- End If
- WriteBackup()
- End Sub
-
-#End Region ' Verify
-
-#End Region ' COMMANDS
-
-End Class
-
-Public Class Door
- Inherits VMBase
-
- Public Enum DoorStates As Integer
- NULL = 0
- LOADED_FROM_CSV = 1
- VERIFIED = 10
- VERIFICATION_FAILED = 11
- SKIPPED = 20
- NOTPRODUCE = 21
- READY_FOR_PRODUCTION = 30
- ON_LOAD_STATION = 31
- MACHINE_1_START = 33
- MACHINE_1_END = 34
- MACHINE_2_START = 35
- MACHINE_2_END = 36
- PRODUCED = 37
- SCRAP = 40
- End Enum
-
- Public Enum DoorProdStates As Integer
- NOT_INIT = 0
- IMPORTED = 1
- SENT_1 = 2
- START_MACHINING_1 = 3
- MACHINED_1 = 4
- SENT_2 = 5
- START_MACHINING_2 = 6
- MACHINED_2 = 7
- UNLOADED = 8
- End Enum
-
- Private m_nId As Integer
- Public ReadOnly Property nId As Integer
- Get
- Return m_nId
- End Get
- End Property
-
- Private m_nCSVLine As Integer
- Public ReadOnly Property nCSVLine As Integer
- Get
- Return m_nCSVLine
- End Get
- End Property
-
- Private m_sDDFName As String
- Public ReadOnly Property sDDFName As String
- Get
- Return m_sDDFName
- End Get
- End Property
-
- Private m_nQuantity As Integer
- Public ReadOnly Property nQuantity As Integer
- Get
- Return m_nQuantity
- End Get
- End Property
-
- Private m_dWidth As Double
- Public ReadOnly Property dWidth As Double
- Get
- Return m_dWidth
- End Get
- End Property
-
- Private m_dHeight As Double
- Public ReadOnly Property dHeight As Double
- Get
- Return m_dHeight
- End Get
- End Property
-
- Private m_dThickness As Double
- Public ReadOnly Property dThickness As Double
- Get
- Return m_dThickness
- End Get
- End Property
-
- Private m_sCSVName As String
- Public ReadOnly Property sCSVName As String
- Get
- Return m_sCSVName
- End Get
- End Property
-
- Private m_CustomerParameters As New List(Of CustomerParameter)
- Public ReadOnly Property CustomerParameters As List(Of CustomerParameter)
- Get
- Return m_CustomerParameters
- End Get
- End Property
-
- Private m_nState As DoorStates = DoorStates.LOADED_FROM_CSV
- Public ReadOnly Property nState As DoorStates
- Get
- Return m_nState
- End Get
- End Property
- Friend Sub SetState(value As DoorStates, Optional bWriteBackup As Boolean = True, Optional bUpdate As Boolean = True)
- m_nState = value
- If bWriteBackup Then Map.refDoorListPageVM.WriteBackup()
- If bUpdate Then
- NotifyPropertyChanged(NameOf(nState))
- NotifyPropertyChanged(NameOf(Background))
- End If
- End Sub
-
-#Region "Statistics"
-
- Private m_nProdState As DoorProdStates = DoorProdStates.NOT_INIT
- Public ReadOnly Property nProdState As DoorProdStates
- Get
- Return m_nProdState
- End Get
- End Property
- Friend Sub SetProdState(value As DoorProdStates)
- m_nProdState = value
- Select Case value
- Case DoorProdStates.SENT_1
- SetState(DoorStates.ON_LOAD_STATION)
- Case DoorProdStates.START_MACHINING_1
- SetState(DoorStates.MACHINE_1_START)
- Case DoorProdStates.MACHINED_1
- SetState(DoorStates.MACHINE_1_END)
- Case DoorProdStates.START_MACHINING_2
- SetState(DoorStates.MACHINE_2_START)
- Case DoorProdStates.MACHINED_2
- SetState(DoorStates.MACHINE_2_END)
- Case DoorProdStates.UNLOADED
- SetState(DoorStates.PRODUCED)
- End Select
- NotifyPropertyChanged(NameOf(nProdState))
- End Sub
-
- Private m_dtLoadTime As DateTime = DateTime.MinValue
- Friend ReadOnly Property dtLoadTime As DateTime
- Get
- Return m_dtLoadTime
- End Get
- End Property
- Public ReadOnly Property sLoadTime As String
- Get
- Return If(m_dtLoadTime <> DateTime.MinValue, m_dtLoadTime.ToString("yy/MM/dd hh:mm:ss"), "")
- End Get
- End Property
- Friend Sub SetLoadTime(LoadTime As Long)
- m_dtLoadTime = New DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(LoadTime).ToLocalTime()
- NotifyPropertyChanged(NameOf(sLoadTime))
- End Sub
-
- Private m_dtMachining1Start As DateTime = DateTime.MinValue
- Friend ReadOnly Property dtMachining1Start As DateTime
- Get
- Return m_dtMachining1Start
- End Get
- End Property
- Public ReadOnly Property sMachining1Start As String
- Get
- Return If(m_dtMachining1Start <> DateTime.MinValue, m_dtMachining1Start.ToString("yy/MM/dd hh:mm:ss"), "")
- End Get
- End Property
- Friend Sub SetMachining1Start(Machining1Start As Long)
- m_dtMachining1Start = New DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(Machining1Start).ToLocalTime()
- NotifyPropertyChanged(NameOf(sMachining1Start))
- End Sub
-
- Private m_dtMachining1End As DateTime = DateTime.MinValue
- Friend ReadOnly Property dtMachining1End As DateTime
- Get
- Return m_dtMachining1End
- End Get
- End Property
- Public ReadOnly Property sMachining1End As String
- Get
- Return If(m_dtMachining1End <> DateTime.MinValue, m_dtMachining1End.ToString("yy/MM/dd hh:mm:ss"), "")
- End Get
- End Property
- Friend Sub SetMachining1End(Machining1End As Long)
- m_dtMachining1End = New DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(Machining1End).ToLocalTime()
- NotifyPropertyChanged(NameOf(sMachining1End))
- End Sub
-
- Private m_dtMachining2Start As DateTime = DateTime.MinValue
- Friend ReadOnly Property dtMachining2Start As DateTime
- Get
- Return m_dtMachining2Start
- End Get
- End Property
- Public ReadOnly Property sMachining2Start As String
- Get
- Return If(m_dtMachining2Start <> DateTime.MinValue, m_dtMachining2Start.ToString("yy/MM/dd hh:mm:ss"), "")
- End Get
- End Property
- Friend Sub SetMachining2Start(Machining2Start As Long)
- m_dtMachining2Start = New DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(Machining2Start).ToLocalTime()
- NotifyPropertyChanged(NameOf(sMachining2Start))
- End Sub
-
- Private m_dtMachining2End As DateTime = DateTime.MinValue
- Friend ReadOnly Property dtMachining2End As DateTime
- Get
- Return m_dtMachining2End
- End Get
- End Property
- Public ReadOnly Property sMachining2End As String
- Get
- Return If(m_dtMachining2End <> DateTime.MinValue, m_dtMachining2End.ToString("yy/MM/dd hh:mm:ss"), "")
- End Get
- End Property
- Friend Sub SetMachining2End(Machining2End As Long)
- m_dtMachining2End = New DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(Machining2End).ToLocalTime()
- NotifyPropertyChanged(NameOf(sMachining2End))
- End Sub
-
- Private m_dtUnloadTime As DateTime = DateTime.MinValue
- Friend ReadOnly Property dtUnloadTime As DateTime
- Get
- Return m_dtUnloadTime
- End Get
- End Property
- Public ReadOnly Property sUnloadTime As String
- Get
- Return If(m_dtUnloadTime <> DateTime.MinValue, m_dtUnloadTime.ToString("yy/MM/dd hh:mm:ss"), "")
- End Get
- End Property
- Friend Sub SetUnloadTime(UnloadTime As Long)
- m_dtUnloadTime = New DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(UnloadTime).ToLocalTime()
- NotifyPropertyChanged(NameOf(sUnloadTime))
- End Sub
-
-#End Region ' Statistics
-
- Public ReadOnly Property Background As SolidColorBrush
- Get
- Select Case m_nState
- Case DoorStates.LOADED_FROM_CSV
- Return Brushes.White
- Case DoorStates.VERIFIED
- Return Dictionary.Effector_Green_Status
- Case DoorStates.VERIFICATION_FAILED
- Return Dictionary.Effector_Red_Status
- Case DoorStates.SKIPPED, DoorStates.NOTPRODUCE
- Return Dictionary.Effector_Yellow_Status
- Case DoorStates.READY_FOR_PRODUCTION, DoorStates.ON_LOAD_STATION
- Return Dictionary.Effector_LightBlue_Status
- Case DoorStates.MACHINE_1_START
- Return Dictionary.Effector_Blue_Status
- Case DoorStates.MACHINE_1_END
- Return Brushes.Yellow
- Case DoorStates.MACHINE_2_START
- Return Dictionary.Effector_Blue_Status
- Case DoorStates.MACHINE_2_END, DoorStates.PRODUCED
- Return Dictionary.Effector_Gray_Status
- Case DoorStates.SCRAP
- Return Brushes.MediumPurple
- Case Else
- Return Brushes.White
- End Select
- End Get
- End Property
-
- Sub New(nId As Integer, nCSVLine As Integer, sDDFName As String, sCSVName As String, nQuantity As Integer, dWidth As Double, dHeight As Double, dThickness As Double, HeaderList As String(), ValueList As String())
- m_nId = nId
- m_nCSVLine = nCSVLine
- m_sDDFName = sDDFName
- m_sCSVName = sCSVName
- m_nQuantity = nQuantity
- m_dHeight = dHeight
- m_dWidth = dWidth
- m_dThickness = dThickness
- If Not IsNothing(HeaderList) AndAlso HeaderList.Count > 0 AndAlso Not IsNothing(ValueList) AndAlso ValueList.Count > 0 Then
- For nParamIndex = 0 To Math.Max(HeaderList.Count, ValueList.Count) - 1
- m_CustomerParameters.Add(New CustomerParameter(If(HeaderList.Count > nParamIndex, HeaderList(nParamIndex), ""), If(ValueList.Count > nParamIndex, ValueList(nParamIndex), "")))
- Next
- End If
- End Sub
-
- Sub New(JsonDoor As JsonDoor)
- m_nId = JsonDoor.nId
- m_nCSVLine = JsonDoor.nCSVLine
- m_sDDFName = JsonDoor.sDDFName
- m_sCSVName = JsonDoor.sCSVName
- m_nQuantity = JsonDoor.nQuantity
- m_dHeight = JsonDoor.dHeight
- m_dWidth = JsonDoor.dWidth
- m_dThickness = JsonDoor.dThickness
- m_nState = JsonDoor.nState
- m_CustomerParameters = JsonDoor.CustomerParameters
- m_nProdState = JsonDoor.nProdState
- m_dtLoadTime = JsonDoor.dtLoadTime
- m_dtMachining1Start = JsonDoor.dtMachining1Start
- m_dtMachining1End = JsonDoor.dtMachining1End
- m_dtMachining2Start = JsonDoor.dtMachining2Start
- m_dtMachining2End = JsonDoor.dtMachining2End
- m_dtUnloadTime = JsonDoor.dtUnloadTime
- End Sub
-
-End Class
-
-Public Class CustomerParameter
-
- Private m_sHeader As String
- Public ReadOnly Property sHeader As String
- Get
- Return m_sHeader
- End Get
- End Property
-
- Private m_sValue As String
- Public ReadOnly Property sValue As String
- Get
- Return m_sValue
- End Get
- End Property
-
- Sub New(sHeader As String, sValue As String)
- m_sHeader = sHeader
- m_sValue = sValue
- End Sub
-
-End Class
-
-Public Class StateToSelColorConverter
- Implements IValueConverter
-
- Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.Convert
- If Not TypeOf value Is DoorStates Then Return Brushes.Aqua
- Select Case value
- Case DoorStates.LOADED_FROM_CSV
- Return Dictionary.Effector_White_SelStatus
- Case DoorStates.VERIFIED
- Return Dictionary.Effector_Green_SelStatus
- Case DoorStates.VERIFICATION_FAILED
- Return Dictionary.Effector_Red_SelStatus
- Case DoorStates.SKIPPED
- Return Dictionary.Effector_Yellow_SelStatus
- Case DoorStates.READY_FOR_PRODUCTION, DoorStates.ON_LOAD_STATION
- Return Dictionary.Effector_LightBlue_SelStatus
- Case DoorStates.MACHINE_1_START, DoorStates.MACHINE_2_START
- Return Dictionary.Effector_Blue_SelStatus
- Case DoorStates.MACHINE_1_END
- Return Dictionary.Effector_Blue_SelStatus
- Case DoorStates.MACHINE_2_END, DoorStates.PRODUCED
- Return Dictionary.Effector_Gray_SelStatus
- Case DoorStates.SCRAP
- Return Dictionary.Effector_White_SelStatus
- Case Else
- Return Dictionary.Effector_White_SelStatus
- End Select
- End Function
-
- Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
- Throw New NotImplementedException()
- End Function
-
-End Class
\ No newline at end of file
diff --git a/Effector.Plugin.FiveLakes/MachinePage/MachinePageV.xaml b/Effector.Plugin.FiveLakes/MachinePage/MachinePageV.xaml
index 293a78d..f4a1486 100644
--- a/Effector.Plugin.FiveLakes/MachinePage/MachinePageV.xaml
+++ b/Effector.Plugin.FiveLakes/MachinePage/MachinePageV.xaml
@@ -10,6 +10,7 @@
+
@@ -43,7 +44,8 @@
+ VerticalAlignment="Center"
+ Visibility="{Binding MachineCommands_Visibility}">
@@ -773,6 +775,17 @@
+
+
+
+
+
+
+
0 Then
+ m_dDdfCalcValue = 0
+ End If
+ NotifyPropertyChanged(NameOf(dDdfCalcValue))
+ NotifyPropertyChanged(NameOf(nDDfCalcState))
End If
If LuaGetGlobVar("MACHINE1.NewDoorState", nState) Then
SetNewDoorState(nState)
@@ -962,6 +977,20 @@ Public Class StringToDDFCalcStateConverter
End Class
+Public Class DDFCalcStateToVisibilityConverter
+ Implements IValueConverter
+
+ Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.Convert
+ If TypeOf value IsNot Integer Then Return Visibility.Collapsed
+ Return If(value = 0, Visibility.Collapsed, Visibility.Visible)
+ End Function
+
+ Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
+ Throw New NotImplementedException()
+ End Function
+
+End Class
+
Public Class StringToNewDoorStateConverter
Implements IValueConverter
diff --git a/Effector.Plugin.FiveLakes/Utility/Dictionary.xaml b/Effector.Plugin.FiveLakes/Utility/Dictionary.xaml
index 7b46ab1..86534bd 100644
--- a/Effector.Plugin.FiveLakes/Utility/Dictionary.xaml
+++ b/Effector.Plugin.FiveLakes/Utility/Dictionary.xaml
@@ -250,6 +250,13 @@
+
+
diff --git a/Effector.Plugin.FiveLakes/Utility/JsonUtility.vb b/Effector.Plugin.FiveLakes/Utility/JsonUtility.vb
index 71965e4..226b531 100644
--- a/Effector.Plugin.FiveLakes/Utility/JsonUtility.vb
+++ b/Effector.Plugin.FiveLakes/Utility/JsonUtility.vb
@@ -61,6 +61,13 @@ Public Class JsonDoor
End Get
End Property
+ Private m_nSwing As Integer
+ Public ReadOnly Property nSwing As Integer
+ Get
+ Return m_nSwing
+ End Get
+ End Property
+
Private m_sCSVName As String
Public ReadOnly Property sCSVName As String
Get
@@ -140,7 +147,7 @@ Public Class JsonDoor
#End Region ' Statistics
- Sub New(nListIndex As Integer, nId As Integer, nCSVLine As Integer, sDDFName As String, sCSVName As String, nQuantity As Integer, dWidth As Double, dHeight As Double, dThickness As Double, nState As DoorStates, CustomerParameters As List(Of CustomerParameter),
+ Sub New(nListIndex As Integer, nId As Integer, nCSVLine As Integer, sDDFName As String, sCSVName As String, nQuantity As Integer, dWidth As Double, dHeight As Double, dThickness As Double, nSwing As Integer, nState As DoorStates, CustomerParameters As List(Of CustomerParameter),
nProdState As DoorProdStates, dtLoadTime As DateTime, dtMachining1Start As DateTime, dtMachining1End As DateTime, dtMachining2Start As DateTime, dtMachining2End As DateTime, dtUnloadTime As DateTime)
m_nListIndex = nListIndex
m_nId = nId
@@ -151,6 +158,7 @@ Public Class JsonDoor
m_dHeight = dHeight
m_dWidth = dWidth
m_dThickness = dThickness
+ m_nSwing = nSwing
m_nState = nState
m_CustomerParameters = CustomerParameters
m_nProdState = nProdState
@@ -172,6 +180,7 @@ Public Class JsonDoor
m_dHeight = Door.dHeight
m_dWidth = Door.dWidth
m_dThickness = Door.dThickness
+ m_nSwing = Door.nSwing
m_nState = Door.nState
m_CustomerParameters = Door.CustomerParameters
m_nProdState = Door.nProdState