- eliminazione commenti e cose inutili

This commit is contained in:
Emmanuele Sassi
2026-05-11 19:04:04 +02:00
parent ae7768425e
commit 9768e3b80d
4 changed files with 86 additions and 207 deletions
@@ -2,10 +2,6 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Effector.Plugin.StoneCut">
<Grid.Resources>
<local:StateToSelColorConverter x:Key="StateToSelColorConverter"/>
<local:DDTListToBooleanConverter x:Key="DDTListToBooleanConverter"/>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="3"/>
@@ -233,12 +229,12 @@
<DataGrid.RowStyle>
<Style TargetType="{x:Type DataGridRow}" BasedOn="{StaticResource RowDataGrid_CustomHighLight}">
<Setter Property="Background" Value="{Binding Background}"/>
<Setter Property="Foreground" Value="{Binding Foreground}"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="BorderBrush" Value="Green"/>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="{Binding Background}"/>
<Setter Property="Foreground" Value="{Binding Foreground}"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="BorderBrush" Value="Green"/>
<Setter Property="BorderThickness" Value="2,0,2,0"/>
</Trigger>
@@ -248,12 +244,12 @@
<DataGrid.CellStyle>
<Style TargetType="{x:Type DataGridCell}">
<Setter Property="Background" Value="{Binding Background}"/>
<Setter Property="Foreground" Value="{Binding Foreground}"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="BorderBrush" Value="{Binding Background}"/>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="{Binding Background}"/>
<Setter Property="Foreground" Value="{Binding Foreground}"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="BorderBrush" Value="{Binding Background}"/>
</Trigger>
</Style.Triggers>
@@ -14,8 +14,6 @@ Public Class DoorListPageVM
Inherits VMBase
Private m_BackupTimer As New DispatcherTimer
Private m_WriteCSVTimer As New DispatcherTimer
Private m_RefreshGraphicsTimer As New DispatcherTimer
Private m_ExecProcessManager As ExecProcessManager
Private m_ReadPartProgramFolderTimer As New DispatcherTimer
@@ -195,28 +193,7 @@ Public Class DoorListPageVM
ResetProductionQueue()
m_BackupTimer.Interval = New TimeSpan(0, 0, 1)
AddHandler m_BackupTimer.Tick, AddressOf BackupTimer_Tick
m_WriteCSVTimer.Interval = New TimeSpan(0, 1, 0)
AddHandler m_WriteCSVTimer.Tick, AddressOf WriteCSVTimer_Tick
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 = False
If GetPluginPrivateProfileInt(S_GENERAL, K_ISCSVOUTPUTENABLED, 0) = 1 Then
bStartWriteCSV = True
If GetPluginPrivateProfileString(S_GENERAL, K_CSVOUTPUTPATH, "", 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
If bStartWriteCSV Then
m_WriteCSVTimer.Start()
End If
End If
m_RefreshGraphicsTimer.Start()
' leggo path cartella dei partprogram
GetPluginPrivateProfileString(S_GENERAL, "PartProgramFolder", "", m_sPartProgramFolderPath)
@@ -333,83 +310,6 @@ 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
'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.PartProgramStates.VERIFIED, Door.PartProgramStates.VERIFICATION_FAILED))
' ' elimino file generati
' Dim sGenDDFDirPath As String = ""
' GetPluginPrivateProfileString(S_GENERAL, K_GENDDFDIR, "", sGenDDFDirPath)
' Dim sDoorFileName As String = Path.GetFileNameWithoutExtension(CurrRequestDoor.sFileName) & "_" & 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")
' '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")
' '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
' If CopyGenDdfFile(CurrRequestDoor, CurrDoor) Then
' CurrDoor.SetState(If(ArgumentsResult.nResult = 0, Door.PartProgramStates.VERIFIED, Door.PartProgramStates.VERIFICATION_FAILED))
' End If
' 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))
'End If
'If Not bExecButton_IsEnabled AndAlso m_ExecProcessManager.ExecutionThreadStatus = ExecProcessManager.ExecutionThreadStatuses.STOPPED Then
' SetExecButtonIsEnabled(True)
'End If
'NotifyPropertyChanged(NameOf(ExecPercentage_Visibility))
End Sub
Friend Function GetNextDoor() As Door
Dim NextDoor As Door = m_DoorList.FirstOrDefault(Function(x) x.nState = Door.PartProgramStates.READY_FOR_PRODUCTION)
If Not IsNothing(NextDoor) Then
@@ -429,14 +329,6 @@ Public Class DoorListPageVM
Return nId
End Function
Friend Sub ResetStateAfterReset()
'For Each Door In m_DoorList
' If Door.nState > Door.PartProgramStates.VERIFIED AndAlso Door.nState < Door.PartProgramStates.MACHINE_1_END Then
' Door.SetState(Door.PartProgramStates.VERIFIED, False)
' End If
'Next
End Sub
#End Region ' METHODS
#Region "COMMANDS"
@@ -461,7 +353,6 @@ Public Class DoorListPageVM
End If
End Sub
#End Region ' CopyDoor
#Region "MoveUp"
@@ -658,14 +549,6 @@ 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 PartProgramStates As Integer
NULL = 0
READY_FOR_PRODUCTION = 1
@@ -769,10 +652,6 @@ Public Class Door
m_dtMachiningStart = dtMachiningStart
NotifyPropertyChanged(NameOf(sMachiningStart))
End Sub
'Friend Sub SetMachiningStart(Machining1Start As Long)
' m_dtMachiningStart = New DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(Machining1Start).ToLocalTime()
' NotifyPropertyChanged(NameOf(sMachiningStart))
'End Sub
Private m_dtMachiningEnd As DateTime = DateTime.MinValue
Friend ReadOnly Property dtMachiningEnd As DateTime
@@ -820,12 +699,6 @@ Public Class Door
End Get
End Property
Public ReadOnly Property Foreground As SolidColorBrush
Get
Return Brushes.White
End Get
End Property
' Definizione comandi
Private m_cmdNotProduce As ICommand
@@ -890,82 +763,11 @@ Public Class Door
Public Sub NotProduce()
If nState = Door.PartProgramStates.PRODUCED Then Return
SetState(If(nState = Door.PartProgramStates.NULL, Door.PartProgramStates.NOTPRODUCE, Door.PartProgramStates.NULL))
SetState(If(nState = Door.PartProgramStates.NULL OrElse nState = Door.PartProgramStates.MACHINE_START, Door.PartProgramStates.NOTPRODUCE, Door.PartProgramStates.NULL))
End Sub
#End Region ' NotProduceDoor
#End Region ' COMMANDS
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
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 PartProgramStates Then Return Brushes.Aqua
Select Case value
'Case PartProgramStates.LOADED_FROM_CSV
' Return Dictionary.Effector_White_SelStatus
'Case PartProgramStates.VERIFIED
' Return Dictionary.Effector_Green_SelStatus
'Case PartProgramStates.VERIFICATION_FAILED
' Return Dictionary.Effector_Red_SelStatus
Case PartProgramStates.NOTPRODUCE
Return Dictionary.Effector_Yellow_SelStatus
Case PartProgramStates.READY_FOR_PRODUCTION
Return Dictionary.Effector_LightBlue_SelStatus
Case PartProgramStates.MACHINE_START
Return Dictionary.Effector_Blue_SelStatus
Case PartProgramStates.PRODUCED
Return Dictionary.Effector_Gray_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
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
@@ -143,6 +143,7 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="Utility\EgtInterface.vb" />
<Compile Include="Utility\JsonUtility.vb" />
<Compile Include="Utility\Map.vb" />
<EmbeddedResource Include="My Project\Resources.resx">
@@ -0,0 +1,80 @@
Imports System.Runtime.InteropServices
Imports System.Security
Public Module EgtInterface
#If DEBUG Then
Const EgtIntDll32 As String = "EgtBasisD32.dll"
#Else
Const EgtIntDll32 As String = "EgtBasisR32.dll"
#End If
<DllImport(EgtIntDll32, CharSet:=CharSet.Unicode, EntryPoint:="EgtSetKey"), SuppressUnmanagedCodeSecurity()>
Public Function EgtSetKey(sKey As String) As Boolean
End Function
<DllImport(EgtIntDll32, CharSet:=CharSet.Unicode, EntryPoint:="EgtGetKeyLevel"), SuppressUnmanagedCodeSecurity()>
Public Function EgtGetKeyLevel(nProd As Integer, nVer As Integer, nLev As Integer, ByRef nKLev As Integer) As Boolean
End Function
<DllImport(EgtIntDll32, CharSet:=CharSet.Unicode, EntryPoint:="EgtGetKeyOptions"), SuppressUnmanagedCodeSecurity()>
Public Function EgtGetKeyOptions(nProd As Integer, nVer As Integer, nLev As Integer,
ByRef nOpt1 As UInteger, ByRef nOpt2 As UInteger) As Boolean
End Function
<DllImport(EgtIntDll32, CharSet:=CharSet.Unicode, EntryPoint:="EgtGetKeyLeftDays"), SuppressUnmanagedCodeSecurity()>
Public Function EgtGetKeyLeftDays(ByRef nLeftDays As Integer) As Boolean
End Function
<DllImport(EgtIntDll32, CharSet:=CharSet.Unicode, EntryPoint:="EgtGetKeyAssLeftDays"), SuppressUnmanagedCodeSecurity()>
Public Function EgtGetKeyAssLeftDays(ByRef nAssLeftDays As Integer) As Boolean
End Function
<DllImport(EgtIntDll32, CharSet:=CharSet.Unicode, EntryPoint:="EgtGetKeyOptLeftDays"), SuppressUnmanagedCodeSecurity()>
Public Function EgtGetKeyOptLeftDays(ByRef nOptLeftDays As Integer) As Boolean
End Function
<DllImport(EgtIntDll32, CharSet:=CharSet.Unicode, EntryPoint:="EgtFreeMemory"), SuppressUnmanagedCodeSecurity()>
Public Function EgtFreeMemory(sB As IntPtr) As Boolean
End Function
<DllImport(EgtIntDll32, CharSet:=CharSet.Unicode, EntryPoint:="EgtLoadMessages"), SuppressUnmanagedCodeSecurity()>
Public Function EgtLoadMessages(sMsgFilePath As String) As Boolean
End Function
<DllImport(EgtIntDll32, CharSet:=CharSet.Unicode, EntryPoint:="EgtGetMsg"), SuppressUnmanagedCodeSecurity()>
Private Function EgtGetMsg_32(nId As Integer) As IntPtr
End Function
Public Function EgtMsg(nId As Integer) As String
Return Marshal.PtrToStringUni(EgtGetMsg_32(nId))
' Non è necessario liberare la memoria nativa perchè usa un buffer statico
End Function
<DllImport(EgtIntDll32, CharSet:=CharSet.Unicode, EntryPoint:="EgtInitLogger"), SuppressUnmanagedCodeSecurity()>
Public Function EgtInitLogger(nDebug As Integer, sLogFilePath As String) As Boolean
End Function
<DllImport(EgtIntDll32, CharSet:=CharSet.Unicode, EntryPoint:="EgtOutLog"), SuppressUnmanagedCodeSecurity()>
Private Function EgtOutLog(sMsg As String, nDebugLevel As Integer) As Boolean
End Function
<DllImport(EgtIntDll32, CharSet:=CharSet.Unicode, EntryPoint:="EgtGetStringUtf8FromIni"), SuppressUnmanagedCodeSecurity()>
Private Function EgtGetStringUtf8FromIni_32(sSec As String, sKey As String, sDef As String, ByRef sVal As IntPtr, sIniFile As String) As Boolean
End Function
Public Function EgtGetStringUtf8FromIni(sSec As String, sKey As String, sDef As String, ByRef sVal As String, sIniFile As String) As Boolean
Dim psVal As IntPtr
Dim bOk As Boolean = EgtGetStringUtf8FromIni_32(sSec, sKey, sDef, psVal, sIniFile)
If bOk Then
sVal = Marshal.PtrToStringUni(psVal)
EgtFreeMemory(psVal)
Else
sVal = String.Empty
End If
Return bOk
End Function
<DllImport(EgtIntDll32, CharSet:=CharSet.Unicode, EntryPoint:="EgtWriteStringUtf8ToIni"), SuppressUnmanagedCodeSecurity()>
Public Function EgtWriteStringUtf8toIni(sSec As String, sKey As String, sVal As String, sIniFile As String) As Boolean
End Function
End Module