diff --git a/Effector.Plugin.FiveLakes.sln b/Effector.Plugin.FiveLakes.sln index 781f5b1..dfa3a56 100644 --- a/Effector.Plugin.FiveLakes.sln +++ b/Effector.Plugin.FiveLakes.sln @@ -9,6 +9,8 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Effector.Plugin.Interface", EndProject Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Effector.Plugin.FiveLakes", "Effector.Plugin.FiveLakes\Effector.Plugin.FiveLakes.vbproj", "{7C77F537-8235-40AB-B24A-4E71CFB96D2C}" EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Effector.Plugin.Lib", "..\Effector.Plugin.Lib\Effector.Plugin.Lib\Effector.Plugin.Lib.vbproj", "{E5ECC5E1-EA7B-447D-9A07-F5EE25D27779}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -55,6 +57,18 @@ Global {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Release|x64.Build.0 = Release|Any CPU {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Release|x86.ActiveCfg = Release|Any CPU {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Release|x86.Build.0 = Release|Any CPU + {E5ECC5E1-EA7B-447D-9A07-F5EE25D27779}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E5ECC5E1-EA7B-447D-9A07-F5EE25D27779}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E5ECC5E1-EA7B-447D-9A07-F5EE25D27779}.Debug|x64.ActiveCfg = Debug|Any CPU + {E5ECC5E1-EA7B-447D-9A07-F5EE25D27779}.Debug|x64.Build.0 = Debug|Any CPU + {E5ECC5E1-EA7B-447D-9A07-F5EE25D27779}.Debug|x86.ActiveCfg = Debug|Any CPU + {E5ECC5E1-EA7B-447D-9A07-F5EE25D27779}.Debug|x86.Build.0 = Debug|Any CPU + {E5ECC5E1-EA7B-447D-9A07-F5EE25D27779}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E5ECC5E1-EA7B-447D-9A07-F5EE25D27779}.Release|Any CPU.Build.0 = Release|Any CPU + {E5ECC5E1-EA7B-447D-9A07-F5EE25D27779}.Release|x64.ActiveCfg = Release|Any CPU + {E5ECC5E1-EA7B-447D-9A07-F5EE25D27779}.Release|x64.Build.0 = Release|Any CPU + {E5ECC5E1-EA7B-447D-9A07-F5EE25D27779}.Release|x86.ActiveCfg = Release|Any CPU + {E5ECC5E1-EA7B-447D-9A07-F5EE25D27779}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Effector.Plugin.FiveLakes/Constants/ConstIni.vb b/Effector.Plugin.FiveLakes/Constants/ConstIni.vb index fab97d5..70bcd17 100644 --- a/Effector.Plugin.FiveLakes/Constants/ConstIni.vb +++ b/Effector.Plugin.FiveLakes/Constants/ConstIni.vb @@ -15,10 +15,12 @@ Module ConstIni Public Const INI_FILE_NAME As String = "Effector.Plugin.FiveLakes.ini" Public Const S_GENERAL As String = "General" + Public Const K_CAMEXEPATH As String = "CAMExePath" Public Const K_BACKUPDIR As String = "BackupDir" Public Const K_RESOURCESDIR As String = "ResourcesDir" Public Const K_DDFDIR As String = "DDFDir" Public Const K_GENDDFDIR As String = "GenDDFDir" + Public Const K_CSVOUTPUT As String = "CSVOutput" Public Const S_CSV As String = "CSV" Public Const K_DDFNAME As String = "DDFName" @@ -26,6 +28,11 @@ 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_STATE As String = "State" + Public Const K_PROGRAMSENT As String = "ProgramSent" + Public Const K_PROGRAMSTART As String = "ProgramStart" + Public Const K_PROGRAMEND As String = "ProgramEnd" + Public Const K_MANUALADDEDDOORNAME As String = "ManualAddedDoorName" Public Const K_DELIMITER As String = "Delimiter" Public Const S_DEBUG As String = "Debug" diff --git a/Effector.Plugin.FiveLakes/DoorListPage/DoorListPageV.xaml b/Effector.Plugin.FiveLakes/DoorListPage/DoorListPageV.xaml index 8382235..3034b84 100644 --- a/Effector.Plugin.FiveLakes/DoorListPage/DoorListPageV.xaml +++ b/Effector.Plugin.FiveLakes/DoorListPage/DoorListPageV.xaml @@ -1,103 +1,246 @@  + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:local="clr-namespace:Effector.Plugin.FiveLakes"> + + + + - - + + + + + + + + + + + + + + + + + + + ScrollViewer.VerticalScrollBarVisibility="Auto" + ScrollViewer.HorizontalScrollBarVisibility="Disabled" + HorizontalGridLinesBrush="Transparent" + VerticalGridLinesBrush="Transparent" + ColumnHeaderHeight="32" + HeadersVisibility="Column" + FontSize="12" + FontFamily="/Resources/Fonts/#Roboto" + FontWeight="Regular" + RowHeight="32" + BorderThickness="0"> + + + - - - + - - - + Width="1*" + MinWidth="100" + IsReadOnly="True" + ElementStyle="{StaticResource DataGridTextColumn_TextBlock}" + EditingElementStyle="{StaticResource DataGridTextColumn_TextBox}"/> + Width="Auto" + IsReadOnly="True" + ElementStyle="{StaticResource DataGridTextColumn_TextBlock}" + EditingElementStyle="{StaticResource DataGridTextColumn_TextBox}"/> + - + + + Width="Auto" + IsReadOnly="True" + ElementStyle="{StaticResource DataGridTextColumn_TextBlock}" + EditingElementStyle="{StaticResource DataGridTextColumn_TextBox}"/> + + Width="Auto" + IsReadOnly="True" + ElementStyle="{StaticResource DataGridTextColumn_TextBlock}" + EditingElementStyle="{StaticResource DataGridTextColumn_TextBox}"/> + Width="Auto" + IsReadOnly="True" + ElementStyle="{StaticResource DataGridTextColumn_TextBlock}" + EditingElementStyle="{StaticResource DataGridTextColumn_TextBox}"/> + Width="Auto" + IsReadOnly="True" + ElementStyle="{StaticResource DataGridTextColumn_TextBlock}" + EditingElementStyle="{StaticResource DataGridTextColumn_TextBox}"/> + Width="Auto" + IsReadOnly="True" + ElementStyle="{StaticResource DataGridTextColumn_TextBlock}" + EditingElementStyle="{StaticResource DataGridTextColumn_TextBox}"/> + Width="Auto" + IsReadOnly="True" + ElementStyle="{StaticResource DataGridTextColumn_TextBlock}" + EditingElementStyle="{StaticResource DataGridTextColumn_TextBox}"/> + Width="Auto" + IsReadOnly="True" + ElementStyle="{StaticResource DataGridTextColumn_TextBlock}" + EditingElementStyle="{StaticResource DataGridTextColumn_TextBox}"/> + Width="Auto" + IsReadOnly="True" + ElementStyle="{StaticResource DataGridTextColumn_TextBlock}" + EditingElementStyle="{StaticResource DataGridTextColumn_TextBox}"/> - diff --git a/Effector.Plugin.FiveLakes/DoorListPage/DoorListPageVM.vb b/Effector.Plugin.FiveLakes/DoorListPage/DoorListPageVM.vb index 5f5e3f7..2a710a6 100644 --- a/Effector.Plugin.FiveLakes/DoorListPage/DoorListPageVM.vb +++ b/Effector.Plugin.FiveLakes/DoorListPage/DoorListPageVM.vb @@ -3,6 +3,9 @@ Imports System.IO Imports Newtonsoft.Json Imports System.Windows.Threading Imports System.Text.RegularExpressions +Imports Effector.Plugin.FiveLakes.Door +Imports System.Globalization +Imports Effector.Plugin.Lib Public Class DoorListPageVM Inherits VMBase @@ -41,9 +44,38 @@ Public Class DoorListPageVM Private m_nBackupindex As Integer = 0 Private m_bWritingBackup As Boolean = False + Private m_sCSVOutDirPath As String = "" + + Private m_nExecIncrement As Integer = 0 + Private m_nExecutedArgsCount As Integer = 0 + Public ReadOnly Property dExecPercentage As Double + Get + Dim dExecIncrement As Double = If(IsNothing(m_ExecProcessManager) OrElse m_ExecProcessManager.nArgsInQueue = 0, 0, Math.Min(28, m_nExecIncrement) / 34) + Return If(IsNothing(m_ExecProcessManager), 0, (m_ExecProcessManager.nExecutedArgsCounter + dExecIncrement) / (m_ExecProcessManager.nExecutedArgsCounter + m_ExecProcessManager.nArgsInQueue)) * 100 + End Get + End Property + + Public ReadOnly Property sExecPercentage As String + Get + Return DoubleToString(dExecPercentage, 1) & "%" + End Get + End Property + + Public ReadOnly Property ExecPercentage_Visibility As Visibility + Get + Dim x = If(Not IsNothing(m_ExecProcessManager) AndAlso m_ExecProcessManager.ExecutionThreadStatus = ExecProcessManager.ExecutionThreadStatuses.RUNNING, Visibility.Visible, Visibility.Collapsed) + Return If(Not IsNothing(m_ExecProcessManager) AndAlso m_ExecProcessManager.ExecutionThreadStatus = ExecProcessManager.ExecutionThreadStatuses.RUNNING, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + ' Definizione comandi Private m_cmdOpenCSV As ICommand + Private m_cmdSaveCSV As ICommand Private m_cmdSkipDoor As ICommand + Private m_cmdNotProduceDoor As ICommand + Private m_cmdAddDoor As ICommand + Private m_cmdCopyDoor As ICommand + Private m_cmdMultipleCopyDoor As ICommand Private m_cmdMoveUp As ICommand Private m_cmdMoveDown As ICommand Private m_cmdDelete As ICommand @@ -58,6 +90,7 @@ Public Class DoorListPageVM Sub New() ' imposto riferimento in Map Map.SetRefDoorListPageVM(Me) + ' leggo backup Dim sBackupDirPath As String = "" GetPluginPrivateProfileString(S_GENERAL, "BackupDir", "", sBackupDirPath) Dim sBackupFilePath As String = sBackupDirPath & "\Backup.json" @@ -67,6 +100,16 @@ Public Class DoorListPageVM m_RefreshGraphicsTimer.Interval = New TimeSpan(0, 0, 1) AddHandler m_RefreshGraphicsTimer.Tick, AddressOf RefreshGraphicsTimer_Tick m_BackupTimer.Start() + ' verifico path salvataggio CSV + Dim bStartWriteCSV As Boolean = True + If GetPluginPrivateProfileString(S_GENERAL, K_CSVOUTPUT, "", m_sCSVOutDirPath) = 0 Then + bStartWriteCSV = False + MessageBox.Show("Path di salvataggio CSV non impostata! Impossibile creare file CSV!", "Errore!", MessageBoxButton.OK, MessageBoxImage.Error) + End If + If bStartWriteCSV AndAlso Not Directory.Exists(m_sCSVOutDirPath) Then + bStartWriteCSV = False + MessageBox.Show("Path di salvataggio CSV impostata non esiste! Impossibile creare file CSV!", "Errore!", MessageBoxButton.OK, MessageBoxImage.Error) + End If m_RefreshGraphicsTimer.Start() End Sub #End Region ' CONSTRUCTOR @@ -103,8 +146,15 @@ Public Class DoorListPageVM 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()) + Dim TempDoorList As ObservableCollection(Of Door) = New ObservableCollection(Of Door)((From JsonDoor In JsonDoorList + Select New Door(JsonDoor)).ToList()) + For Each CurrDoor In TempDoorList + If CurrDoor.nState >= Door.DoorStates.READY_FOR_PRODUCTION Then + CurrDoor.SetState(Door.DoorStates.VERIFIED, False) + End If + Next + WriteBackup() + m_DoorList = TempDoorList End Sub Public Sub Write(FilePath As String) @@ -190,9 +240,20 @@ Public Class DoorListPageVM WriteBackup() ArgumentsResult = m_ExecProcessManager.ArgumentsResultDequeue End While + ' aggiorno grafica + If Not bExecButton_IsEnabled AndAlso m_ExecProcessManager.ExecutionThreadStatus = ExecProcessManager.ExecutionThreadStatuses.RUNNING Then + NotifyPropertyChanged(NameOf(dExecPercentage)) + NotifyPropertyChanged(NameOf(sExecPercentage)) + End If 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 Friend Function GetNextDoor() As Door @@ -205,13 +266,14 @@ Public Class DoorListPageVM 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 + Friend Function NewDoorId() As Integer + Dim nId As Integer = 1 + If m_DoorList.Count > 0 Then + Dim nMaxId As Integer = m_DoorList.Max(Of Integer)(Function(x) x.nId) + nId = nMaxId + 1 + End If + Return nId + End Function #End Region ' METHODS @@ -281,7 +343,7 @@ Public Class DoorListPageVM 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" + sLineErrorList &= "Quantity not readable in line " & sLine & ". This line will be skipped" & Environment.NewLine Continue While End If End If @@ -304,13 +366,7 @@ Public Class DoorListPageVM 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 nId As Integer = NewDoorId() Dim NewDoor As New Door(nId, nLineIndex, Values(nDDFNameIndex), Path.GetFileName(sCSVPath), 1, dWidth, dHeight, dThickness, Headers, Values) m_DoorList.Add(NewDoor) @@ -392,6 +448,161 @@ Public Class DoorListPageVM #End Region ' OpenCSV +#Region "SaveCSV" + + Public ReadOnly Property SaveCSV_Command As ICommand + Get + If m_cmdSaveCSV Is Nothing Then + m_cmdSaveCSV = New Command(AddressOf SaveCSV) + End If + Return m_cmdSaveCSV + End Get + End Property + + Public Sub SaveCSV() + ' leggo nomi intestazioni da ini + Dim sDDFName As String = "" + Dim sQuantityName As String = "" + Dim sHeightName As String = "" + Dim sWidthName As String = "" + Dim sThicknessName As String = "" + Dim sStateName As String = "" + Dim sProgramSentName As String = "" + Dim sProgramStartName As String = "" + Dim sProgramEndName 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_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) + For Each CSVFile In CSVFileList + Dim CSVDoorList As List(Of Door) = (From Door In m_DoorList + Where Door.sCSVName = CSVFile).ToList() + Dim sCSVOutPath = m_sCSVOutDirPath & "\Output_" & DateTime.Now().ToString("yy-MM-dd-HH-mm-ss") & ".csv" + Dim sCSVFileList As New List(Of String) + Dim sHeaderRow As String = "" + For Each Parameter In CSVDoorList(0).CustomerParameters + ' evito di scrivere la quantita' + If Parameter.sHeader <> sQuantityName Then + sHeaderRow &= Parameter.sHeader & ";" + End If + Next + ' aggiungo titoli per tempi di produzione + sHeaderRow &= sStateName & ";" & sProgramSentName & ";" & sProgramStartName & ";" & sProgramEndName + sHeaderRow.TrimEnd(";"c) + sCSVFileList.Add(sHeaderRow) + For Each Door In CSVDoorList + Dim DDFNameParameter As CustomerParameter = Door.CustomerParameters.FirstOrDefault(Function(x) x.sHeader = sDDFName) + If Not IsNothing(DDFNameParameter) Then + DDFNameParameter.SetValue(Door.sDDFName) + End If + Dim HeightNameParameter As CustomerParameter = Door.CustomerParameters.FirstOrDefault(Function(x) x.sHeader = sHeightName) + If Not IsNothing(HeightNameParameter) Then + HeightNameParameter.SetValue(DoubleToString(Door.dHeight, 2)) + End If + Dim WidthNameParameter As CustomerParameter = Door.CustomerParameters.FirstOrDefault(Function(x) x.sHeader = sWidthName) + If Not IsNothing(WidthNameParameter) Then + WidthNameParameter.SetValue(DoubleToString(Door.dWidth, 2)) + End If + Dim ThicknessNameParameter As CustomerParameter = Door.CustomerParameters.FirstOrDefault(Function(x) x.sHeader = sThicknessName) + If Not IsNothing(ThicknessNameParameter) Then + ThicknessNameParameter.SetValue(DoubleToString(Door.dThickness, 2)) + End If + Dim sDoorRow As String = "" + For Each Parameter In Door.CustomerParameters + ' evito di scrivere la quantita' + If Parameter.sHeader <> sQuantityName Then + sDoorRow &= Parameter.sValue & ";" + End If + Next + ' aggiungo valori per tempi di produzione + Dim sState As String = "" + If Door.nState < DoorStates.MACHINE_1_START Then + sState = "DaProdurre" + ElseIf Door.nState = DoorStates.MACHINE_1_START Then + sState = "InProduzione" + Else + sState = "Prodotto" + End If + sDoorRow &= sState & ";" & Door.sLoadTime & ";" & Door.sMachining1Start & ";" & Door.sMachining1End + sCSVFileList.Add(sDoorRow) + Next + Try + File.WriteAllLines(sCSVOutPath, sCSVFileList) + 'MessageBox.Show("Csv salvato in " & m_sCSVOutDirPath, "Info", MessageBoxButton.OK, MessageBoxImage.Information) + Catch ex As Exception + MessageBox.Show("Creazione file csv fallita!" & Environment.NewLine & ex.Message, "Errore", MessageBoxButton.OK, MessageBoxImage.Error) + End Try + + + Next + + + + + 'Dim CSVDoorList As List(Of Door) = (From Door In m_DoorList + ' Where Door.sCSVName = m_SelDoor.sCSVName).ToList() + 'sCSVOutPath &= "\" & m_SelDoor.sCSVName + 'Dim sCSVFileList As New List(Of String) + 'Dim sHeaderRow As String = "" + 'For Each Parameter In m_SelDoor.CustomerParameters + ' ' evito di scrivere la quantita' + ' If Parameter.sHeader <> sQuantityName Then + ' sHeaderRow &= Parameter.sHeader & ";" + ' End If + 'Next + 'sHeaderRow.TrimEnd(";"c) + 'sCSVFileList.Add(sHeaderRow) + 'For Each Door In CSVDoorList + ' Dim DDFNameParameter As CustomerParameter = Door.CustomerParameters.FirstOrDefault(Function(x) x.sHeader = sDDFName) + ' If Not IsNothing(DDFNameParameter) Then + ' DDFNameParameter.SetValue(Door.sDDFName) + ' End If + ' Dim HeightNameParameter As CustomerParameter = Door.CustomerParameters.FirstOrDefault(Function(x) x.sHeader = sHeightName) + ' If Not IsNothing(HeightNameParameter) Then + ' HeightNameParameter.SetValue(DoubleToString(Door.dHeight, 2)) + ' End If + ' Dim WidthNameParameter As CustomerParameter = Door.CustomerParameters.FirstOrDefault(Function(x) x.sHeader = sWidthName) + ' If Not IsNothing(WidthNameParameter) Then + ' WidthNameParameter.SetValue(DoubleToString(Door.dWidth, 2)) + ' End If + ' Dim ThicknessNameParameter As CustomerParameter = Door.CustomerParameters.FirstOrDefault(Function(x) x.sHeader = sThicknessName) + ' 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' + ' If Parameter.sHeader <> sQuantityName Then + ' sDoorRow &= Parameter.sValue & ";" + ' End If + ' Next + ' sCSVFileList.Add(sDoorRow) + 'Next + 'Try + ' File.WriteAllLines(sCSVOutPath, sCSVFileList) + ' MessageBox.Show("Csv salvato in " & sCSVOutPath, "Info", MessageBoxButton.OK, MessageBoxImage.Information) + 'Catch ex As Exception + ' MessageBox.Show("Creazione file csv fallita!", "Errore", MessageBoxButton.OK, MessageBoxImage.Error) + 'End Try + End Sub + +#End Region ' SaveCSV + #Region "SkipDoor" Public ReadOnly Property SkipDoor_Command As ICommand @@ -411,6 +622,114 @@ Public Class DoorListPageVM #End Region ' SkipDoor +#Region "NotProduceDoor" + + Public ReadOnly Property NotProduceDoor_Command As ICommand + Get + If m_cmdNotProduceDoor Is Nothing Then + m_cmdNotProduceDoor = New Command(AddressOf NotProduceDoor) + End If + Return m_cmdNotProduceDoor + End Get + End Property + + Public Sub NotProduceDoor() + If Not IsNothing(SelDoor) Then + If (Keyboard.Modifiers And ModifierKeys.Shift) = ModifierKeys.Shift Then + If (SelDoor.nState <> Door.DoorStates.VERIFIED AndAlso SelDoor.nState <> Door.DoorStates.NOTPRODUCE) Then Return + Dim sSelCSVName As String = SelDoor.sCSVName + Dim SelDoorState As Door.DoorStates = SelDoor.nState + For Each CsvDoor In m_DoorList + If String.Compare(sSelCSVName, CsvDoor.sCSVName, True) = 0 Then + If CsvDoor.nState = DoorStates.VERIFIED OrElse CsvDoor.nState = DoorStates.NOTPRODUCE Then + CsvDoor.SetState(If(SelDoorState = Door.DoorStates.VERIFIED, Door.DoorStates.NOTPRODUCE, Door.DoorStates.VERIFIED)) + End If + End If + Next + Else + If (SelDoor.nState <> Door.DoorStates.VERIFIED AndAlso SelDoor.nState <> Door.DoorStates.NOTPRODUCE) Then Return + SelDoor.SetState(If(SelDoor.nState = Door.DoorStates.VERIFIED, Door.DoorStates.NOTPRODUCE, Door.DoorStates.VERIFIED)) + End If + End If + WriteBackup() + End Sub + +#End Region ' NotProduceDoor + +#Region "AddDoor" + + Public ReadOnly Property AddDoor_Command As ICommand + Get + If m_cmdAddDoor Is Nothing Then + m_cmdAddDoor = New Command(AddressOf AddDoor) + End If + Return m_cmdAddDoor + End Get + End Property + + 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, {}, {})) + End Sub + +#End Region ' AddDoor + +#Region "CopyDoor" + + Public ReadOnly Property CopyDoor_Command As ICommand + Get + If m_cmdCopyDoor Is Nothing Then + m_cmdCopyDoor = New Command(AddressOf CopyDoorCmd) + End If + Return m_cmdCopyDoor + End Get + End Property + + Public Sub CopyDoorCmd() + If IsNothing(SelDoor) Then + MessageBox.Show("Nessuna porta selezionata!" & Environment.NewLine & "Selezionare la porta da copiare", "Errore!", MessageBoxButton.OK, MessageBoxImage.Error) + Return + End If + CopyDoor() + End Sub + + Public Sub CopyDoor() + Dim nId As Integer = NewDoorId() + m_DoorList.Add(SelDoor.Copy(nId)) + End Sub + +#End Region ' CopyDoor + +#Region "MultipleCopyDoor" + + Public ReadOnly Property MultipleCopyDoor_Command As ICommand + Get + If m_cmdMultipleCopyDoor Is Nothing Then + m_cmdMultipleCopyDoor = New Command(AddressOf MultipleCopyDoor) + End If + Return m_cmdMultipleCopyDoor + End Get + End Property + + Public Sub MultipleCopyDoor() + If IsNothing(SelDoor) Then + MessageBox.Show("Nessuna porta selezionata!" & Environment.NewLine & "Selezionare la porta da copiare", "Errore!", MessageBoxButton.OK, MessageBoxImage.Error) + Return + End If + ' apro finestra quantita' + Dim MultipleCopyWndVM As New MultipleCopyWndVM + Dim MultipleCopyWnd As New MultipleCopyWndV(Application.Current.MainWindow, MultipleCopyWndVM) + If MultipleCopyWnd.ShowDialog() Then + For Index = 1 To MultipleCopyWndVM.nCopyNumber + CopyDoor() + Next + End If + End Sub + +#End Region ' MultipleCopyDoor + #Region "MoveUp" Public ReadOnly Property MoveUp_Command As ICommand @@ -466,7 +785,13 @@ Public Class DoorListPageVM End Property Public Sub Delete() - If IsNothing(SelDoor) OrElse SelDoor.nState >= Door.DoorStates.READY_FOR_PRODUCTION Then Return + 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 + 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 + 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) WriteBackup() @@ -487,12 +812,29 @@ Public Class DoorListPageVM End Property Public Sub DeleteAll() - If m_DoorList.Count = 0 Then Return + 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 + 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 + bAllProduced = False + End If + End If + Next + If Not bAllProduced Then + MessageBox.Show("Selected CSV delete impossible!" & Environment.NewLine & "To be able to delete it all the lines needs to be in state Produced or NotProduced", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning) + Return + End If 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) + For CsvDoorIndex = m_DoorList.Count - 1 To 0 Step -1 + Dim CsvDoor As Door = m_DoorList(CsvDoorIndex) + If String.Compare(sSelCSVName, CsvDoor.sCSVName, True) = 0 Then + m_DoorList.Remove(CsvDoor) + End If Next WriteBackup() End If @@ -518,6 +860,7 @@ Public Class DoorListPageVM 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.NOTPRODUCE OrElse DoorToProduce.nState = Door.DoorStates.VERIFICATION_FAILED OrElse DoorToProduce.nState >= Door.DoorStates.READY_FOR_PRODUCTION Then Return ' la sposto dopo l'ultima da produrre @@ -567,6 +910,14 @@ Public Class DoorListPageVM WriteBackup() End Sub + Public Sub ResetProductionQueue() + For Each Door In m_DoorList + If Door.nState = Door.DoorStates.READY_FOR_PRODUCTION Then + Door.SetState(Door.DoorStates.VERIFIED) + End If + Next + End Sub + #End Region ' ResetProductionQueue #Region "Verify" @@ -623,6 +974,7 @@ Public Class Door VERIFIED = 10 VERIFICATION_FAILED = 11 SKIPPED = 20 + NOTPRODUCE = 21 READY_FOR_PRODUCTION = 30 ON_LOAD_STATION = 31 MACHINE_1_START = 33 @@ -853,22 +1205,22 @@ Public Class Door 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 Brushes.Red - Case DoorStates.SKIPPED - Return Brushes.Orange - Case DoorStates.READY_FOR_PRODUCTION - Return Brushes.LightSkyBlue - Case DoorStates.ON_LOAD_STATION - Return Brushes.SkyBlue + 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 Brushes.DodgerBlue + Return Dictionary.Effector_Blue_Status Case DoorStates.MACHINE_1_END Return Brushes.Yellow Case DoorStates.MACHINE_2_START - Return Brushes.DodgerBlue + Return Dictionary.Effector_Blue_Status Case DoorStates.MACHINE_2_END, DoorStates.PRODUCED - Return Brushes.LightGray + Return Dictionary.Effector_Gray_Status Case DoorStates.SCRAP Return Brushes.MediumPurple Case Else @@ -893,6 +1245,18 @@ 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)) + m_nId = nId + m_nCSVLine = nCSVLine + m_sDDFName = sDDFName + m_sCSVName = sCSVName + m_nQuantity = nQuantity + m_dHeight = dHeight + m_dWidth = dWidth + m_dThickness = dThickness + m_CustomerParameters = CustomerParameters + End Sub + Sub New(JsonDoor As JsonDoor) m_nId = JsonDoor.nId m_nCSVLine = JsonDoor.nCSVLine @@ -913,6 +1277,16 @@ Public Class Door m_dtUnloadTime = JsonDoor.dtUnloadTime End Sub +#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) + End Function + +#End Region ' METHODS + End Class Public Class CustomerParameter @@ -930,10 +1304,48 @@ Public Class CustomerParameter Return m_sValue End Get End Property + Friend Sub SetValue(value As String) + m_sValue = value + End Sub 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/DoorListPage/DoorListPageVM.vb.bak b/Effector.Plugin.FiveLakes/DoorListPage/DoorListPageVM.vb.bak new file mode 100644 index 0000000..2e27f60 --- /dev/null +++ b/Effector.Plugin.FiveLakes/DoorListPage/DoorListPageVM.vb.bak @@ -0,0 +1,977 @@ +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/Effector.Plugin.FiveLakes.vbproj b/Effector.Plugin.FiveLakes/Effector.Plugin.FiveLakes.vbproj index fec2214..816ff61 100644 --- a/Effector.Plugin.FiveLakes/Effector.Plugin.FiveLakes.vbproj +++ b/Effector.Plugin.FiveLakes/Effector.Plugin.FiveLakes.vbproj @@ -51,6 +51,9 @@ ..\..\Effector.Main\Effector.Plugin.Interface\bin\Debug\Effector.Plugin.Interface.dll + + ..\..\Effector.Plugin.Lib\Effector.Plugin.Lib\bin\Debug\Effector.Plugin.Lib.dll + ..\packages\KeraLua.1.4.1\lib\net46\KeraLua.dll @@ -98,9 +101,6 @@ DoorListPageV.xaml - - ProcessManagerV.xaml - FiveLakesUI.xaml @@ -116,7 +116,6 @@ MainMenuV.xaml - RestartWndV.xaml @@ -142,7 +141,6 @@ True - @@ -160,16 +158,14 @@ Settings.Designer.vb + + Designer MSBuild:Compile - - Designer - MSBuild:Compile - Designer MSBuild:Compile @@ -195,6 +191,27 @@ MSBuild:Compile + + + + + + + + + + + + + + + + + + + + + powershell.exe -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -File $(ProjectDir)\pre-build.ps1 -ProjectDir $(ProjectDir) -ProjectPath $(ProjectPath) diff --git a/Effector.Plugin.FiveLakes/FiveLakesUI.xaml b/Effector.Plugin.FiveLakes/FiveLakesUI.xaml index 8367c04..bb10719 100644 --- a/Effector.Plugin.FiveLakes/FiveLakesUI.xaml +++ b/Effector.Plugin.FiveLakes/FiveLakesUI.xaml @@ -3,12 +3,8 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Effector.Plugin.FiveLakes" DataContext="{StaticResource FiveLakesUIVM}"> - - - - + @@ -22,11 +18,4 @@ - diff --git a/Effector.Plugin.FiveLakes/FiveLakesUIVM.vb b/Effector.Plugin.FiveLakes/FiveLakesUIVM.vb index 4621e1b..6ec2da6 100644 --- a/Effector.Plugin.FiveLakes/FiveLakesUIVM.vb +++ b/Effector.Plugin.FiveLakes/FiveLakesUIVM.vb @@ -53,6 +53,7 @@ Public Class FiveLakesUIVM m_sConfigDir = m_sDataRoot & "\" & CONF_DIR ' Impostazione path Ini file IniFile.SetIniFile(m_sConfigDir & "\" & INI_FILE_NAME) + Effector.Plugin.Lib.PluginIniFile.SetIniFile(m_sConfigDir & "\" & INI_FILE_NAME) ' Impostazione path resources dir m_sResourcesRoot = m_sDataRoot & "\" & RES_DIR End Sub diff --git a/Effector.Plugin.FiveLakes/MainMenu/MainMenuV.xaml b/Effector.Plugin.FiveLakes/MainMenu/MainMenuV.xaml index 142cf0f..91bfaa3 100644 --- a/Effector.Plugin.FiveLakes/MainMenu/MainMenuV.xaml +++ b/Effector.Plugin.FiveLakes/MainMenu/MainMenuV.xaml @@ -14,19 +14,19 @@ - + Style="{StaticResource MainMenu_ToggleButton}"/> - + diff --git a/Effector.Plugin.FiveLakes/ProcessManager/ProcessManagerV.xaml b/Effector.Plugin.FiveLakes/ProcessManager/ProcessManagerV.xaml index d749df5..818bec2 100644 --- a/Effector.Plugin.FiveLakes/ProcessManager/ProcessManagerV.xaml +++ b/Effector.Plugin.FiveLakes/ProcessManager/ProcessManagerV.xaml @@ -1,57 +1,67 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + diff --git a/Effector.Plugin.FiveLakes/ProcessManager/ProcessManagerVM.vb b/Effector.Plugin.FiveLakes/ProcessManager/ProcessManagerVM.vb index 03ddb50..285111f 100644 --- a/Effector.Plugin.FiveLakes/ProcessManager/ProcessManagerVM.vb +++ b/Effector.Plugin.FiveLakes/ProcessManager/ProcessManagerVM.vb @@ -1,5 +1,6 @@ Imports System.Windows.Threading Imports System.Collections.ObjectModel +Imports Effector.Plugin.Lib Public Class ProcessManagerVM Inherits VMBase diff --git a/Effector.Plugin.FiveLakes/Resources/DoorListPage/Add.png b/Effector.Plugin.FiveLakes/Resources/DoorListPage/Add.png new file mode 100644 index 0000000..b634987 Binary files /dev/null and b/Effector.Plugin.FiveLakes/Resources/DoorListPage/Add.png differ diff --git a/Effector.Plugin.FiveLakes/Resources/DoorListPage/Copy.png b/Effector.Plugin.FiveLakes/Resources/DoorListPage/Copy.png new file mode 100644 index 0000000..add0b01 Binary files /dev/null and b/Effector.Plugin.FiveLakes/Resources/DoorListPage/Copy.png differ diff --git a/Effector.Plugin.FiveLakes/Resources/DoorListPage/Delete.png b/Effector.Plugin.FiveLakes/Resources/DoorListPage/Delete.png new file mode 100644 index 0000000..539802f Binary files /dev/null and b/Effector.Plugin.FiveLakes/Resources/DoorListPage/Delete.png differ diff --git a/Effector.Plugin.FiveLakes/Resources/DoorListPage/DeleteCsv.png b/Effector.Plugin.FiveLakes/Resources/DoorListPage/DeleteCsv.png new file mode 100644 index 0000000..5096a59 Binary files /dev/null and b/Effector.Plugin.FiveLakes/Resources/DoorListPage/DeleteCsv.png differ diff --git a/Effector.Plugin.FiveLakes/Resources/DoorListPage/MoveDown.png b/Effector.Plugin.FiveLakes/Resources/DoorListPage/MoveDown.png new file mode 100644 index 0000000..8769109 Binary files /dev/null and b/Effector.Plugin.FiveLakes/Resources/DoorListPage/MoveDown.png differ diff --git a/Effector.Plugin.FiveLakes/Resources/DoorListPage/MoveUp.png b/Effector.Plugin.FiveLakes/Resources/DoorListPage/MoveUp.png new file mode 100644 index 0000000..46606d5 Binary files /dev/null and b/Effector.Plugin.FiveLakes/Resources/DoorListPage/MoveUp.png differ diff --git a/Effector.Plugin.FiveLakes/Resources/DoorListPage/MultipleCopy.png b/Effector.Plugin.FiveLakes/Resources/DoorListPage/MultipleCopy.png new file mode 100644 index 0000000..6be8813 Binary files /dev/null and b/Effector.Plugin.FiveLakes/Resources/DoorListPage/MultipleCopy.png differ diff --git a/Effector.Plugin.FiveLakes/Resources/DoorListPage/NotProduce.png b/Effector.Plugin.FiveLakes/Resources/DoorListPage/NotProduce.png new file mode 100644 index 0000000..63f6a8d Binary files /dev/null and b/Effector.Plugin.FiveLakes/Resources/DoorListPage/NotProduce.png differ diff --git a/Effector.Plugin.FiveLakes/Resources/DoorListPage/OpenCsv.png b/Effector.Plugin.FiveLakes/Resources/DoorListPage/OpenCsv.png new file mode 100644 index 0000000..c5e3518 Binary files /dev/null and b/Effector.Plugin.FiveLakes/Resources/DoorListPage/OpenCsv.png differ diff --git a/Effector.Plugin.FiveLakes/Resources/DoorListPage/Produce.png b/Effector.Plugin.FiveLakes/Resources/DoorListPage/Produce.png new file mode 100644 index 0000000..3b5e99f Binary files /dev/null and b/Effector.Plugin.FiveLakes/Resources/DoorListPage/Produce.png differ diff --git a/Effector.Plugin.FiveLakes/Resources/DoorListPage/ProduceAll.old.png b/Effector.Plugin.FiveLakes/Resources/DoorListPage/ProduceAll.old.png new file mode 100644 index 0000000..322244c Binary files /dev/null and b/Effector.Plugin.FiveLakes/Resources/DoorListPage/ProduceAll.old.png differ diff --git a/Effector.Plugin.FiveLakes/Resources/DoorListPage/ProduceAll.png b/Effector.Plugin.FiveLakes/Resources/DoorListPage/ProduceAll.png new file mode 100644 index 0000000..ebd13b7 Binary files /dev/null and b/Effector.Plugin.FiveLakes/Resources/DoorListPage/ProduceAll.png differ diff --git a/Effector.Plugin.FiveLakes/Resources/DoorListPage/ResetProduction.png b/Effector.Plugin.FiveLakes/Resources/DoorListPage/ResetProduction.png new file mode 100644 index 0000000..48976c9 Binary files /dev/null and b/Effector.Plugin.FiveLakes/Resources/DoorListPage/ResetProduction.png differ diff --git a/Effector.Plugin.FiveLakes/Resources/DoorListPage/SaveCsv.png b/Effector.Plugin.FiveLakes/Resources/DoorListPage/SaveCsv.png new file mode 100644 index 0000000..d085eee Binary files /dev/null and b/Effector.Plugin.FiveLakes/Resources/DoorListPage/SaveCsv.png differ diff --git a/Effector.Plugin.FiveLakes/Resources/DoorListPage/SkipDoor.png b/Effector.Plugin.FiveLakes/Resources/DoorListPage/SkipDoor.png new file mode 100644 index 0000000..ef66656 Binary files /dev/null and b/Effector.Plugin.FiveLakes/Resources/DoorListPage/SkipDoor.png differ diff --git a/Effector.Plugin.FiveLakes/Resources/DoorListPage/Verify.png b/Effector.Plugin.FiveLakes/Resources/DoorListPage/Verify.png new file mode 100644 index 0000000..e1305e8 Binary files /dev/null and b/Effector.Plugin.FiveLakes/Resources/DoorListPage/Verify.png differ diff --git a/Effector.Plugin.FiveLakes/Resources/Fonts/Roboto-Light.ttf b/Effector.Plugin.FiveLakes/Resources/Fonts/Roboto-Light.ttf new file mode 100644 index 0000000..d43e943 Binary files /dev/null and b/Effector.Plugin.FiveLakes/Resources/Fonts/Roboto-Light.ttf differ diff --git a/Effector.Plugin.FiveLakes/Resources/Fonts/Roboto-Regular.ttf b/Effector.Plugin.FiveLakes/Resources/Fonts/Roboto-Regular.ttf new file mode 100644 index 0000000..7d9a6c4 Binary files /dev/null and b/Effector.Plugin.FiveLakes/Resources/Fonts/Roboto-Regular.ttf differ diff --git a/Effector.Plugin.FiveLakes/Utility/Dictionary.xaml b/Effector.Plugin.FiveLakes/Utility/Dictionary.xaml index f206425..7b46ab1 100644 --- a/Effector.Plugin.FiveLakes/Utility/Dictionary.xaml +++ b/Effector.Plugin.FiveLakes/Utility/Dictionary.xaml @@ -16,43 +16,88 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + - - + - - + + + + + + + + + + + + @@ -65,6 +110,174 @@ 2 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - diff --git a/Effector.Plugin.FiveLakes/Utility/Dictionary.xaml.vb b/Effector.Plugin.FiveLakes/Utility/Dictionary.xaml.vb index a33f325..5af06c5 100644 --- a/Effector.Plugin.FiveLakes/Utility/Dictionary.xaml.vb +++ b/Effector.Plugin.FiveLakes/Utility/Dictionary.xaml.vb @@ -12,77 +12,125 @@ Public Class Dictionary #Region "Colors" - 'Private m_Omag_Red As SolidColorBrush = Brushes.Red - 'Public ReadOnly Property Omag_Red As SolidColorBrush + Private Shared m_Effector_LightBlue As SolidColorBrush = Application.Current.FindResource("Effector_LightBlue") + Public Shared ReadOnly Property Effector_LightBlue As SolidColorBrush + Get + Return m_Effector_LightBlue + End Get + End Property + + Private Shared m_Effector_Blue As SolidColorBrush = Application.Current.FindResource("Effector_Blue") + Public Shared ReadOnly Property Effector_Blue As SolidColorBrush + Get + Return m_Effector_Blue + End Get + End Property + + Private Shared m_Effector_DarkBlue As SolidColorBrush = Application.Current.FindResource("Effector_DarkBlue") + Public Shared ReadOnly Property Effector_DarkBlue As SolidColorBrush + Get + Return m_Effector_DarkBlue + End Get + End Property + + Private Shared m_Effector_LightBlue_Status As SolidColorBrush = Application.Current.FindResource("Effector_LightBlue_Status") + Public Shared ReadOnly Property Effector_LightBlue_Status As SolidColorBrush + Get + Return m_Effector_LightBlue_Status + End Get + End Property + + Private Shared m_Effector_Blue_Status As SolidColorBrush = Application.Current.FindResource("Effector_Blue_Status") + Public Shared ReadOnly Property Effector_Blue_Status As SolidColorBrush + Get + Return m_Effector_Blue_Status + End Get + End Property + + Private Shared m_Effector_Red_Status As SolidColorBrush = Application.Current.FindResource("Effector_Red_Status") + Public Shared ReadOnly Property Effector_Red_Status As SolidColorBrush + Get + Return m_Effector_Red_Status + End Get + End Property + + Private Shared m_Effector_Green_Status As SolidColorBrush = Application.Current.FindResource("Effector_Green_Status") + Public Shared ReadOnly Property Effector_Green_Status As SolidColorBrush + Get + Return m_Effector_Green_Status + End Get + End Property + + Private Shared m_Effector_Gray_Status As SolidColorBrush = Application.Current.FindResource("Effector_Gray_Status") + Public Shared ReadOnly Property Effector_Gray_Status As SolidColorBrush + Get + Return m_Effector_Gray_Status + End Get + End Property + + Private Shared m_Effector_Yellow_Status As SolidColorBrush = Application.Current.FindResource("Effector_Yellow_Status") + Public Shared ReadOnly Property Effector_Yellow_Status As SolidColorBrush + Get + Return m_Effector_Yellow_Status + End Get + End Property + + Private Shared m_Effector_LightBlue_SelStatus As SolidColorBrush = Application.Current.FindResource("Effector_LightBlue_SelStatus") + Public Shared ReadOnly Property Effector_LightBlue_SelStatus As SolidColorBrush + Get + Return m_Effector_LightBlue_SelStatus + End Get + End Property + + Private Shared m_Effector_Blue_SelStatus As SolidColorBrush = Application.Current.FindResource("Effector_Blue_SelStatus") + Public Shared ReadOnly Property Effector_Blue_SelStatus As SolidColorBrush + Get + Return m_Effector_Blue_SelStatus + End Get + End Property + + Private Shared m_Effector_Red_SelStatus As SolidColorBrush = Application.Current.FindResource("Effector_Red_SelStatus") + Public Shared ReadOnly Property Effector_Red_SelStatus As SolidColorBrush + Get + Return m_Effector_Red_SelStatus + End Get + End Property + + Private Shared m_Effector_Green_SelStatus As SolidColorBrush = Application.Current.FindResource("Effector_Green_SelStatus") + Public Shared ReadOnly Property Effector_Green_SelStatus As SolidColorBrush + Get + Return m_Effector_Green_SelStatus + End Get + End Property + + Private Shared m_Effector_Gray_SelStatus As SolidColorBrush = Application.Current.FindResource("Effector_Gray_SelStatus") + Public Shared ReadOnly Property Effector_Gray_SelStatus As SolidColorBrush + Get + Return m_Effector_Gray_SelStatus + End Get + End Property + + Private Shared m_Effector_Yellow_SelStatus As SolidColorBrush = Application.Current.FindResource("Effector_Yellow_SelStatus") + Public Shared ReadOnly Property Effector_Yellow_SelStatus As SolidColorBrush + Get + Return m_Effector_Yellow_SelStatus + End Get + End Property + + Private Shared m_Effector_White_SelStatus As SolidColorBrush = Application.Current.FindResource("Effector_White_SelStatus") + Public Shared ReadOnly Property Effector_White_SelStatus As SolidColorBrush + Get + Return m_Effector_White_SelStatus + End Get + End Property + + 'Private Shared m_Effector_Orange As SolidColorBrush = Application.Current.FindResource("Effector_Orange") + 'Public Shared ReadOnly Property Effector_Orange As SolidColorBrush ' Get - ' Return m_Omag_Red + ' Return m_Effector_Orange ' End Get 'End Property - 'Private Shared m_Button_Static_Background As SolidColorBrush = New BrushConverter().ConvertFrom("#FFDDDDDD") - 'Public Shared ReadOnly Property Button_Static_Background As SolidColorBrush - ' Get - ' Return m_Button_Static_Background - ' End Get - 'End Property - - 'Private Shared m_TabControl_Header_Background As LinearGradientBrush = Application.Current.FindResource("TabItem.Static.Background") - 'Public Shared ReadOnly Property TabControl_Header_Background As LinearGradientBrush - ' Get - ' Return m_TabControl_Header_Background - ' End Get - 'End Property - - - 'Private Shared m_Icarus_Gray As SolidColorBrush = Application.Current.FindResource("Icarus_Gray") - 'Public Shared ReadOnly Property Icarus_Gray As SolidColorBrush - ' Get - ' Return m_Icarus_Gray - ' End Get - 'End Property - - 'Private Shared m_Icarus_LightBlue As SolidColorBrush = Application.Current.FindResource("Icarus_LightBlue") - 'Public Shared ReadOnly Property Icarus_LightBlue As SolidColorBrush - ' Get - ' Return m_Icarus_LightBlue - ' End Get - 'End Property - - 'Private Shared m_Icarus_Blue As SolidColorBrush = Application.Current.FindResource("Icarus_Blue") - 'Public Shared ReadOnly Property Icarus_Blue As SolidColorBrush - ' Get - ' Return m_Icarus_Blue - ' End Get - 'End Property - - 'Private Shared m_Icarus_Green As SolidColorBrush = Application.Current.FindResource("Icarus_Green") - 'Public Shared ReadOnly Property Icarus_Green As SolidColorBrush - ' Get - ' Return m_Icarus_Green - ' End Get - 'End Property - - 'Private Shared m_Icarus_Orange As SolidColorBrush = Application.Current.FindResource("Icarus_Orange") - 'Public Shared ReadOnly Property Icarus_Orange As SolidColorBrush - ' Get - ' Return m_Icarus_Orange - ' End Get - 'End Property - - 'Private Shared m_Icarus_Purple As SolidColorBrush = Application.Current.FindResource("Icarus_Purple") - 'Public Shared ReadOnly Property Icarus_Purple As SolidColorBrush - ' Get - ' Return m_Icarus_Purple - ' End Get - 'End Property - - ' - ' - ' - ' - ' - ' - #End Region ' Colors End Class diff --git a/Effector.Plugin.FiveLakes/Utility/ExecProcessManager.vb b/Effector.Plugin.FiveLakes/Utility/ExecProcessManager.vb index 23919df..cf8958c 100644 --- a/Effector.Plugin.FiveLakes/Utility/ExecProcessManager.vb +++ b/Effector.Plugin.FiveLakes/Utility/ExecProcessManager.vb @@ -3,6 +3,7 @@ Imports System.Threading Imports MS.Internal Imports Effector.Plugin.FiveLakes.ThreadData Imports System.Windows.Threading +Imports Effector.Plugin.Lib Public Class ExecProcessManager