|
|
|
@@ -4,6 +4,8 @@ Imports Newtonsoft.Json
|
|
|
|
|
Imports System.Windows.Threading
|
|
|
|
|
Imports System.Text.RegularExpressions
|
|
|
|
|
Imports System.Security.Cryptography
|
|
|
|
|
Imports Newtonsoft.Json.Linq
|
|
|
|
|
Imports Effector.Plugin.DoorArreda.Door
|
|
|
|
|
|
|
|
|
|
Public Class DoorListPageVM
|
|
|
|
|
Inherits VMBase
|
|
|
|
@@ -107,9 +109,9 @@ Public Class DoorListPageVM
|
|
|
|
|
GetPluginPrivateProfileString(S_GENERAL, "CAMExePath", "", sCamExePath)
|
|
|
|
|
Dim sMainLuaPath As String = ""
|
|
|
|
|
GetPluginPrivateProfileString(S_GENERAL, "MainLUA", "", sMainLuaPath)
|
|
|
|
|
Dim sDDFDirPath As String = ""
|
|
|
|
|
GetPluginPrivateProfileString(S_GENERAL, "DDFDir", "", sDDFDirPath)
|
|
|
|
|
Dim sDDFFilePath As String = sDDFDirPath & "\" & sDDFName
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
@@ -119,9 +121,9 @@ Public Class DoorListPageVM
|
|
|
|
|
GetPluginPrivateProfileString(S_GENERAL, "CAMExePath", "", sCamExePath)
|
|
|
|
|
Dim sMainLuaPath As String = ""
|
|
|
|
|
GetPluginPrivateProfileString(S_GENERAL, "MainLUA", "", sMainLuaPath)
|
|
|
|
|
Dim sDDFDirPath As String = ""
|
|
|
|
|
GetPluginPrivateProfileString(S_GENERAL, "DDFDir", "", sDDFDirPath)
|
|
|
|
|
Dim sDDFFilePath As String = sDDFDirPath & "\" & sDDFName
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
@@ -134,10 +136,11 @@ Public Class DoorListPageVM
|
|
|
|
|
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.VERIFIED AndAlso CurrDoor.nState < Door.DoorStates.PRODUCED Then
|
|
|
|
|
CurrDoor.SetState(Door.DoorStates.VERIFIED)
|
|
|
|
|
If CurrDoor.nState > Door.DoorStates.VERIFIED AndAlso CurrDoor.nState < Door.DoorStates.MACHINE_1_END Then
|
|
|
|
|
CurrDoor.SetState(Door.DoorStates.VERIFIED, False)
|
|
|
|
|
End If
|
|
|
|
|
Next
|
|
|
|
|
WriteBackup()
|
|
|
|
|
m_DoorList = TempDoorList
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
@@ -226,7 +229,7 @@ Public Class DoorListPageVM
|
|
|
|
|
Friend Sub ResetStateAfterReset()
|
|
|
|
|
For Each Door In m_DoorList
|
|
|
|
|
If Door.nState > Door.DoorStates.VERIFIED AndAlso Door.nState < Door.DoorStates.PRODUCED Then
|
|
|
|
|
Door.SetState(Door.DoorStates.VERIFIED)
|
|
|
|
|
Door.SetState(Door.DoorStates.VERIFIED, False)
|
|
|
|
|
End If
|
|
|
|
|
Next
|
|
|
|
|
End Sub
|
|
|
|
@@ -299,7 +302,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
|
|
|
|
@@ -321,17 +324,41 @@ Public Class DoorListPageVM
|
|
|
|
|
dThickness = 0
|
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
Dim sErrMessage As String = ""
|
|
|
|
|
Dim sGDDFDirPath As String = ""
|
|
|
|
|
GetPluginPrivateProfileString(S_GENERAL, K_GENDDFDIR, "", sGDDFDirPath)
|
|
|
|
|
Dim sGenDDFFilePath As String = ""
|
|
|
|
|
Dim sCopyDDFFilePath As String = ""
|
|
|
|
|
For nQuantityIndex = 1 To nQuantity
|
|
|
|
|
Dim nId As Integer = NewDoorId()
|
|
|
|
|
Dim NewDoor As New Door(nId, nLineIndex, Values(nDDFNameIndex), Path.GetFileName(sCSVPath),
|
|
|
|
|
1, dWidth, dHeight, dThickness, Headers, Values)
|
|
|
|
|
m_DoorList.Add(NewDoor)
|
|
|
|
|
Dim bOk As Boolean = False
|
|
|
|
|
If nQuantityIndex = 1 Then
|
|
|
|
|
' creo file ddf
|
|
|
|
|
bOk = CreateGenDdfFile(nId, Values(nDDFNameIndex), dWidth, dHeight, dThickness, sErrMessage)
|
|
|
|
|
If bOk Then
|
|
|
|
|
sGenDDFFilePath = sGDDFDirPath & "\" & If(Not String.IsNullOrWhiteSpace(Path.GetDirectoryName(Values(nDDFNameIndex))), Path.GetDirectoryName(Values(nDDFNameIndex)) & "_", "") & Path.GetFileNameWithoutExtension(Values(nDDFNameIndex)) & "_" & nId & ".ddf"
|
|
|
|
|
sCopyDDFFilePath = sGDDFDirPath & "\" & If(Not String.IsNullOrWhiteSpace(Path.GetDirectoryName(Values(nDDFNameIndex))), Path.GetDirectoryName(Values(nDDFNameIndex)) & "_", "") & Path.GetFileNameWithoutExtension(Values(nDDFNameIndex))
|
|
|
|
|
End If
|
|
|
|
|
Else
|
|
|
|
|
Try
|
|
|
|
|
File.Copy(sGenDDFFilePath, sCopyDDFFilePath & "_" & nId & ".ddf")
|
|
|
|
|
bOk = True
|
|
|
|
|
Catch ex As Exception
|
|
|
|
|
|
|
|
|
|
End Try
|
|
|
|
|
End If
|
|
|
|
|
If bOk Then
|
|
|
|
|
m_DoorList.Add(NewDoor)
|
|
|
|
|
End If
|
|
|
|
|
Next
|
|
|
|
|
sLineErrorList &= sErrMessage
|
|
|
|
|
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
|
|
|
|
|
sLineErrorList &= ex.Message & Environment.NewLine
|
|
|
|
|
End Try
|
|
|
|
|
End While
|
|
|
|
|
If Not String.IsNullOrWhiteSpace(sLineErrorList) Then
|
|
|
|
@@ -349,20 +376,23 @@ Public Class DoorListPageVM
|
|
|
|
|
AddHandler m_ExecProcessManager.m_AllArgsProcessed, AddressOf ExecProcessManager_AllArgsProcessed
|
|
|
|
|
m_ExecProcessManager.SetMaxCamInstances(3)
|
|
|
|
|
End If
|
|
|
|
|
Dim sDDFDirPath As String = ""
|
|
|
|
|
GetPluginPrivateProfileString(S_GENERAL, "DDFDir", "", sDDFDirPath)
|
|
|
|
|
Dim sDDTDirPath As String = ""
|
|
|
|
|
GetPluginPrivateProfileString(S_GENERAL, "DDTDir", "", sDDTDirPath)
|
|
|
|
|
'Dim sDDFDirPath As String = ""
|
|
|
|
|
'GetPluginPrivateProfileString(S_GENERAL, "DDFDir", "", sDDFDirPath)
|
|
|
|
|
'Dim sDDTDirPath As String = ""
|
|
|
|
|
'GetPluginPrivateProfileString(S_GENERAL, "DDTDir", "", sDDTDirPath)
|
|
|
|
|
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 sDDTFilePath As String = sDDTDirPath & "\" & Door.sDDFName
|
|
|
|
|
Dim sDDFFilePath As String = sDDFDirPath & "\" & Path.GetDirectoryName(Door.sDDFName) &
|
|
|
|
|
Path.GetFileNameWithoutExtension(Door.sDDFName) & "_" & Door.nId & ".ddf"
|
|
|
|
|
Dim sWidth As String = DoubleToString(Door.dWidth, 2)
|
|
|
|
|
Dim sHeight As String = DoubleToString(Door.dHeight, 2)
|
|
|
|
|
Dim sThickness As String = DoubleToString(Door.dThickness, 2)
|
|
|
|
|
Dim sArgs As String = sDDTFilePath & ";" & sWidth & ";" & sHeight & ";" & sThickness & ";" & sDDFFilePath
|
|
|
|
|
m_ExecProcessManager.ArgumentsEnqueue(New ProcessArgs(Door.nId, sArgs))
|
|
|
|
|
Dim sGenDDFFilePath As String = sGenDDFDirPath & "\" & If(Not String.IsNullOrWhiteSpace(Path.GetDirectoryName(Door.sDDFName)), Path.GetDirectoryName(Door.sDDFName) & "_", "") & Path.GetFileNameWithoutExtension(Door.sDDFName) & "_" & Door.nId & ".ddf"
|
|
|
|
|
'Dim sDDTFilePath As String = sDDTDirPath & "\" & Door.sDDFName
|
|
|
|
|
'Dim sDDFFilePath As String = sDDFDirPath & "\" & Path.GetDirectoryName(Door.sDDFName) &
|
|
|
|
|
' Path.GetFileNameWithoutExtension(Door.sDDFName) & "_" & Door.nId & ".ddf"
|
|
|
|
|
'Dim sWidth As String = DoubleToString(Door.dWidth, 2)
|
|
|
|
|
'Dim sHeight As String = DoubleToString(Door.dHeight, 2)
|
|
|
|
|
'Dim sThickness As String = DoubleToString(Door.dThickness, 2)
|
|
|
|
|
'Dim sArgs As String = sDDTFilePath & ";" & sWidth & ";" & sHeight & ";" & sThickness & ";" & sDDFFilePath
|
|
|
|
|
m_ExecProcessManager.ArgumentsEnqueue(New ProcessArgs(Door.nId, sGenDDFFilePath))
|
|
|
|
|
End If
|
|
|
|
|
Next
|
|
|
|
|
If bStartExecProcessManager OrElse m_ExecProcessManager.ExecutionThreadStatus = ExecProcessManager.ExecutionThreadStatuses.STOPPED Then
|
|
|
|
@@ -373,6 +403,46 @@ Public Class DoorListPageVM
|
|
|
|
|
WriteBackup()
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Private Function CreateGenDdfFile(nId As Integer, sDDFName As String, dWidth As Double, dHeight As Double, dThickness As Double, sErrMessage As String) As Boolean
|
|
|
|
|
' verifico che ci sia il file ddf
|
|
|
|
|
Dim sDDTDirPath As String = ""
|
|
|
|
|
GetPluginPrivateProfileString(S_GENERAL, K_DDTDIR, "", sDDTDirPath)
|
|
|
|
|
Dim sDDFDirPath As String = ""
|
|
|
|
|
GetPluginPrivateProfileString(S_GENERAL, K_DDFDIR, "", sDDFDirPath)
|
|
|
|
|
Dim sGenDDFDirPath As String = ""
|
|
|
|
|
GetPluginPrivateProfileString(S_GENERAL, K_GENDDFDIR, "", sGenDDFDirPath)
|
|
|
|
|
Dim sExtension As String = Path.GetExtension(sDDFName)
|
|
|
|
|
If sExtension.ToLower() = ".ddf" Then
|
|
|
|
|
Dim sDDFFilePath As String = sDDFDirPath & "\" & sDDFName
|
|
|
|
|
If Not File.Exists(sDDFFilePath) Then
|
|
|
|
|
sErrMessage &= "Il nome inserito non corrisponde a nessun file nella cartella dei Ddf (" & sDDFDirPath & ")" & Environment.NewLine
|
|
|
|
|
NotifyPropertyChanged(NameOf(sDDFName))
|
|
|
|
|
Return False
|
|
|
|
|
End If
|
|
|
|
|
' copio il ddf nella cartella dei ddf
|
|
|
|
|
Dim sGenDDFFilePath As String = sGenDDFDirPath & "\" & If(Not String.IsNullOrWhiteSpace(Path.GetDirectoryName(sDDFName)), Path.GetDirectoryName(sDDFName) & "_", "") & Path.GetFileNameWithoutExtension(sDDFName) & "_" & nId & ".ddf"
|
|
|
|
|
Dim bCopy As Boolean = False
|
|
|
|
|
Try
|
|
|
|
|
File.Copy(sDDFFilePath, sGenDDFFilePath, True)
|
|
|
|
|
bCopy = True
|
|
|
|
|
Catch ex As Exception
|
|
|
|
|
sErrMessage &= "Error: Copy file from " & sDDFFilePath & " to " & sGenDDFFilePath & " failed!"
|
|
|
|
|
End Try
|
|
|
|
|
If Not bCopy Then
|
|
|
|
|
Return False
|
|
|
|
|
End If
|
|
|
|
|
ElseIf sExtension.ToLower() = ".ddt" Then
|
|
|
|
|
' se file generato
|
|
|
|
|
If Not Door.CreateDdfFromDdt(nId, sDDFName, dWidth, dHeight, dThickness) Then
|
|
|
|
|
Return False
|
|
|
|
|
End If
|
|
|
|
|
Else
|
|
|
|
|
sErrMessage &= "Estensione del file non riconosciuta!"
|
|
|
|
|
Return False
|
|
|
|
|
End If
|
|
|
|
|
Return True
|
|
|
|
|
End Function
|
|
|
|
|
|
|
|
|
|
Public Sub ExecProcessManager_AllArgsProcessed()
|
|
|
|
|
m_ExecProcessManager.StopExecutionThread()
|
|
|
|
|
End Sub
|
|
|
|
@@ -458,7 +528,7 @@ Public Class DoorListPageVM
|
|
|
|
|
End Try
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
#End Region ' SkipDoor
|
|
|
|
|
#End Region ' SaveCSV
|
|
|
|
|
|
|
|
|
|
#Region "SkipDoor"
|
|
|
|
|
|
|
|
|
@@ -495,7 +565,7 @@ Public Class DoorListPageVM
|
|
|
|
|
m_DoorList.Add(New Door(nId, 0, "", m_ManualAddedDoorName, 1, 0, 0, 0, {}, {}))
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
#End Region ' SkipDoor
|
|
|
|
|
#End Region ' AddDoor
|
|
|
|
|
|
|
|
|
|
#Region "MoveUp"
|
|
|
|
|
|
|
|
|
@@ -552,7 +622,11 @@ Public Class DoorListPageVM
|
|
|
|
|
End Property
|
|
|
|
|
|
|
|
|
|
Public Sub Delete()
|
|
|
|
|
If IsNothing(SelDoor) OrElse (SelDoor.nState >= Door.DoorStates.READY_FOR_PRODUCTION AndAlso SelDoor.nState < Door.DoorStates.PRODUCED) Then Return
|
|
|
|
|
If IsNothing(SelDoor) 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()
|
|
|
|
@@ -577,7 +651,7 @@ Public Class DoorListPageVM
|
|
|
|
|
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 AndAlso Door.nState < Door.DoorStates.PRODUCED Then Continue For
|
|
|
|
|
If Door.nState >= Door.DoorStates.READY_FOR_PRODUCTION AndAlso Door.nState < Door.DoorStates.MACHINE_1_END Then Continue For
|
|
|
|
|
m_DoorList.Remove(Door)
|
|
|
|
|
Next
|
|
|
|
|
WriteBackup()
|
|
|
|
@@ -602,7 +676,7 @@ Public Class DoorListPageVM
|
|
|
|
|
WriteBackup()
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Public Sub ProduceDoor(DoorToProduce As Door)
|
|
|
|
|
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
|
|
|
|
@@ -610,7 +684,7 @@ Public Class DoorListPageVM
|
|
|
|
|
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)
|
|
|
|
|
DoorToProduce.SetState(Door.DoorStates.READY_FOR_PRODUCTION, bWriteBackup)
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
#End Region ' Produce
|
|
|
|
@@ -630,7 +704,7 @@ Public Class DoorListPageVM
|
|
|
|
|
If m_DoorList.Count = 0 Then Return
|
|
|
|
|
For nDoorIndex = 0 To m_DoorList.Count - 1
|
|
|
|
|
Dim CurrDoor As Door = m_DoorList(nDoorIndex)
|
|
|
|
|
ProduceDoor(CurrDoor)
|
|
|
|
|
ProduceDoor(CurrDoor, False)
|
|
|
|
|
Next
|
|
|
|
|
WriteBackup()
|
|
|
|
|
End Sub
|
|
|
|
@@ -687,20 +761,12 @@ Public Class DoorListPageVM
|
|
|
|
|
AddHandler m_ExecProcessManager.m_AllArgsProcessed, AddressOf ExecProcessManager_AllArgsProcessed
|
|
|
|
|
m_ExecProcessManager.SetMaxCamInstances(3)
|
|
|
|
|
End If
|
|
|
|
|
Dim sDDFDirPath As String = ""
|
|
|
|
|
GetPluginPrivateProfileString(S_GENERAL, "DDFDir", "", sDDFDirPath)
|
|
|
|
|
Dim sDDTDirPath As String = ""
|
|
|
|
|
GetPluginPrivateProfileString(S_GENERAL, "DDTDir", "", sDDTDirPath)
|
|
|
|
|
Dim sGenDDFDirPath As String = ""
|
|
|
|
|
GetPluginPrivateProfileString(S_GENERAL, K_GENDDFDIR, "", sGenDDFDirPath)
|
|
|
|
|
For Each Door In m_DoorList
|
|
|
|
|
If Door.nState = Door.DoorStates.LOADED_FROM_CSV Or Door.nState = Door.DoorStates.VERIFICATION_FAILED Then
|
|
|
|
|
Dim sDDTFilePath As String = sDDTDirPath & "\" & Door.sDDFName
|
|
|
|
|
Dim sDDFFilePath As String = sDDFDirPath & "\" & Path.GetDirectoryName(Door.sDDFName) &
|
|
|
|
|
Path.GetFileNameWithoutExtension(Door.sDDFName) & "_" & Door.nId & ".ddf"
|
|
|
|
|
Dim sWidth As String = DoubleToString(Door.dWidth, 2)
|
|
|
|
|
Dim sHeight As String = DoubleToString(Door.dHeight, 2)
|
|
|
|
|
Dim sThickness As String = DoubleToString(Door.dThickness, 2)
|
|
|
|
|
Dim sArgs As String = sDDTFilePath & ";" & sWidth & ";" & sHeight & ";" & sThickness & ";" & sDDFFilePath
|
|
|
|
|
m_ExecProcessManager.ArgumentsEnqueue(New ProcessArgs(Door.nId, sArgs))
|
|
|
|
|
Dim sGenDDFFilePath As String = sGenDDFDirPath & "\" & If(Not String.IsNullOrWhiteSpace(Path.GetDirectoryName(Door.sDDFName)), Path.GetDirectoryName(Door.sDDFName) & "_", "") & Path.GetFileNameWithoutExtension(Door.sDDFName) & "_" & Door.nId & ".ddf"
|
|
|
|
|
m_ExecProcessManager.ArgumentsEnqueue(New ProcessArgs(Door.nId, sGenDDFFilePath))
|
|
|
|
|
End If
|
|
|
|
|
Next
|
|
|
|
|
If bStartExecProcessManager OrElse m_ExecProcessManager.ExecutionThreadStatus = ExecProcessManager.ExecutionThreadStatuses.STOPPED Then
|
|
|
|
@@ -719,6 +785,8 @@ End Class
|
|
|
|
|
Public Class Door
|
|
|
|
|
Inherits VMBase
|
|
|
|
|
|
|
|
|
|
Private Shared m_refWriteBackup As Action
|
|
|
|
|
|
|
|
|
|
Public Enum DoorStates As Integer
|
|
|
|
|
NULL = 0
|
|
|
|
|
LOADED_FROM_CSV = 1
|
|
|
|
@@ -769,32 +837,52 @@ Public Class Door
|
|
|
|
|
Set(value As String)
|
|
|
|
|
' verifico che ci sia il file ddf
|
|
|
|
|
Dim sDDTDirPath As String = ""
|
|
|
|
|
GetPluginPrivateProfileString(S_GENERAL, "DDTDir", "", sDDTDirPath)
|
|
|
|
|
If Not File.Exists(sDDTDirPath & "\" & value) Then
|
|
|
|
|
MessageBox.Show("Il nome inserito non corrisponde a nessun file nella cartella dei Ddt (" & sDDTDirPath & ") ", "File non trovato!", MessageBoxButton.OK, MessageBoxImage.Error)
|
|
|
|
|
NotifyPropertyChanged(NameOf(sDDFName))
|
|
|
|
|
Else
|
|
|
|
|
m_sDDFName = value
|
|
|
|
|
' creo il ddf
|
|
|
|
|
Dim Proc As New Process()
|
|
|
|
|
Proc.StartInfo.FileName = "c:\EgtProg\EgtDOORCreator\EgtDOORCreatorR32.exe"
|
|
|
|
|
Proc.StartInfo.RedirectStandardInput = False
|
|
|
|
|
Proc.StartInfo.RedirectStandardOutput = False
|
|
|
|
|
' Proc.StartInfo.Arguments = 1.ToString() & " """ & sMainLuaPath & """ """ & sArguments & """"
|
|
|
|
|
Proc.StartInfo.Arguments = "c:\EgtData\Effector\Ddf-DoorArreda\Ddt\Prova_Apertura_TEMPLATE.ddt;" & "800.55;1800.33;30.22" & ";c:\EgtData\Effector\Ddf-DoorArreda\Ddt\Prova_Apertura_TEMPLATE.ddf"
|
|
|
|
|
Proc.StartInfo.UseShellExecute = False
|
|
|
|
|
Proc.StartInfo.CreateNoWindow = True
|
|
|
|
|
Dim ExecCounter = 0
|
|
|
|
|
If Proc.Start Then
|
|
|
|
|
While Not Proc.HasExited
|
|
|
|
|
If ExecCounter >= 30 Then
|
|
|
|
|
Proc.Kill()
|
|
|
|
|
Exit While
|
|
|
|
|
End If
|
|
|
|
|
Threading.Thread.Sleep(100)
|
|
|
|
|
ExecCounter += 1
|
|
|
|
|
End While
|
|
|
|
|
GetPluginPrivateProfileString(S_GENERAL, K_DDTDIR, "", sDDTDirPath)
|
|
|
|
|
Dim sDDFDirPath As String = ""
|
|
|
|
|
GetPluginPrivateProfileString(S_GENERAL, K_DDFDIR, "", sDDFDirPath)
|
|
|
|
|
Dim sGenDDFDirPath As String = ""
|
|
|
|
|
GetPluginPrivateProfileString(S_GENERAL, K_GENDDFDIR, "", sGenDDFDirPath)
|
|
|
|
|
Dim sExtension As String = Path.GetExtension(value)
|
|
|
|
|
If sExtension.ToLower() = ".ddf" Then
|
|
|
|
|
Dim sDDFFilePath As String = sDDFDirPath & "\" & value
|
|
|
|
|
If Not File.Exists(sDDFFilePath) Then
|
|
|
|
|
MessageBox.Show("Il nome inserito non corrisponde a nessun file nella cartella dei Ddf (" & sDDFDirPath & ") ", "File non trovato!", MessageBoxButton.OK, MessageBoxImage.Error)
|
|
|
|
|
NotifyPropertyChanged(NameOf(sDDFName))
|
|
|
|
|
Return
|
|
|
|
|
End If
|
|
|
|
|
Me.m_sDDFName = value
|
|
|
|
|
' copio il ddf nella cartella dei ddf
|
|
|
|
|
Dim sGenDDFFilePath As String = sGenDDFDirPath & "\" & If(Not String.IsNullOrWhiteSpace(Path.GetDirectoryName(m_sDDFName)), Path.GetDirectoryName(m_sDDFName) & "_", "") & Path.GetFileNameWithoutExtension(m_sDDFName) & "_" & Me.nId & ".ddf"
|
|
|
|
|
Dim bCopy As Boolean = False
|
|
|
|
|
Try
|
|
|
|
|
File.Copy(sDDFFilePath, sGenDDFFilePath, True)
|
|
|
|
|
bCopy = True
|
|
|
|
|
Catch ex As Exception
|
|
|
|
|
Map.refSupervisorFunction.PlgOutLog("Error: Copy file from " & sDDFFilePath & " to " & sGenDDFFilePath & " failed!")
|
|
|
|
|
End Try
|
|
|
|
|
If bCopy Then
|
|
|
|
|
' riporto indietro stato a da verificare
|
|
|
|
|
Me.m_nState = DoorStates.LOADED_FROM_CSV
|
|
|
|
|
NotifyPropertyChanged(NameOf(nState))
|
|
|
|
|
Else
|
|
|
|
|
NotifyPropertyChanged(NameOf(sDDFName))
|
|
|
|
|
Return
|
|
|
|
|
End If
|
|
|
|
|
ElseIf sExtension.ToLower() = ".ddt" Then
|
|
|
|
|
' se file generato
|
|
|
|
|
If CreateDdfFromDdt(m_nId, value, m_dWidth, m_dHeight, m_dThickness) Then
|
|
|
|
|
Me.m_sDDFName = value
|
|
|
|
|
' riporto indietro stato a da verificare
|
|
|
|
|
Me.m_nState = DoorStates.LOADED_FROM_CSV
|
|
|
|
|
NotifyPropertyChanged(NameOf(nState))
|
|
|
|
|
Else
|
|
|
|
|
NotifyPropertyChanged(NameOf(sDDFName))
|
|
|
|
|
Return
|
|
|
|
|
End If
|
|
|
|
|
Else
|
|
|
|
|
MessageBox.Show("Estensione del file non riconosciuta!", "Errore!", MessageBoxButton.OK, MessageBoxImage.Error)
|
|
|
|
|
NotifyPropertyChanged(NameOf(sDDFName))
|
|
|
|
|
Return
|
|
|
|
|
End If
|
|
|
|
|
End Set
|
|
|
|
|
End Property
|
|
|
|
@@ -807,32 +895,96 @@ Public Class Door
|
|
|
|
|
End Property
|
|
|
|
|
|
|
|
|
|
Private m_dWidth As Double
|
|
|
|
|
Public Property dWidth As Double
|
|
|
|
|
Public Property dWidth As String
|
|
|
|
|
Get
|
|
|
|
|
Return m_dWidth
|
|
|
|
|
Return DoubleToString(m_dWidth, 2)
|
|
|
|
|
End Get
|
|
|
|
|
Set(value As Double)
|
|
|
|
|
m_dWidth = value
|
|
|
|
|
Set(value As String)
|
|
|
|
|
Dim dValue As Double = 0
|
|
|
|
|
If Not StringToDouble(value, dValue) Then
|
|
|
|
|
MessageBox.Show("Dimensione non valida!", "Errore!", MessageBoxButton.OK, MessageBoxImage.Error)
|
|
|
|
|
NotifyPropertyChanged(NameOf(dWidth))
|
|
|
|
|
Return
|
|
|
|
|
End If
|
|
|
|
|
' verifico se file ddf o ddt
|
|
|
|
|
Dim sExtension As String = Path.GetExtension(m_sDDFName)
|
|
|
|
|
If sExtension.ToLower() = ".ddf" Then
|
|
|
|
|
MessageBox.Show("ATTENZIONE! Questa modifica non cambia realmente le dimensioni della porta perchè è selezionato un file ddf!", "Attenzione!", MessageBoxButton.OK, MessageBoxImage.Warning)
|
|
|
|
|
m_dWidth = dValue
|
|
|
|
|
Return
|
|
|
|
|
ElseIf sExtension.ToLower() = ".ddt" Then
|
|
|
|
|
If CreateDdfFromDdt(m_nId, m_sDDFName, dValue, m_dHeight, m_dThickness) Then
|
|
|
|
|
m_dWidth = dValue
|
|
|
|
|
' riporto indietro stato a da verificare
|
|
|
|
|
Me.m_nState = DoorStates.LOADED_FROM_CSV
|
|
|
|
|
NotifyPropertyChanged(NameOf(nState))
|
|
|
|
|
Else
|
|
|
|
|
NotifyPropertyChanged(NameOf(dWidth))
|
|
|
|
|
Return
|
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
End Set
|
|
|
|
|
End Property
|
|
|
|
|
|
|
|
|
|
Private m_dHeight As Double
|
|
|
|
|
Public Property dHeight As Double
|
|
|
|
|
Public Property dHeight As String
|
|
|
|
|
Get
|
|
|
|
|
Return m_dHeight
|
|
|
|
|
Return DoubleToString(m_dHeight, 2)
|
|
|
|
|
End Get
|
|
|
|
|
Set(value As Double)
|
|
|
|
|
m_dHeight = value
|
|
|
|
|
Set(value As String)
|
|
|
|
|
Dim dValue As Double = 0
|
|
|
|
|
If Not StringToDouble(value, dValue) Then
|
|
|
|
|
MessageBox.Show("Dimensione non valida!", "Errore!", MessageBoxButton.OK, MessageBoxImage.Error)
|
|
|
|
|
NotifyPropertyChanged(NameOf(dHeight))
|
|
|
|
|
Return
|
|
|
|
|
End If
|
|
|
|
|
' verifico se file ddf o ddt
|
|
|
|
|
Dim sExtension As String = Path.GetExtension(m_sDDFName)
|
|
|
|
|
If sExtension.ToLower() = ".ddf" Then
|
|
|
|
|
m_dHeight = dValue
|
|
|
|
|
Return
|
|
|
|
|
ElseIf sExtension.ToLower() = ".ddt" Then
|
|
|
|
|
If CreateDdfFromDdt(m_nId, m_sDDFName, m_dWidth, dValue, m_dThickness) Then
|
|
|
|
|
m_dHeight = dValue
|
|
|
|
|
' riporto indietro stato a da verificare
|
|
|
|
|
Me.m_nState = DoorStates.LOADED_FROM_CSV
|
|
|
|
|
NotifyPropertyChanged(NameOf(nState))
|
|
|
|
|
Else
|
|
|
|
|
NotifyPropertyChanged(NameOf(dHeight))
|
|
|
|
|
Return
|
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
End Set
|
|
|
|
|
End Property
|
|
|
|
|
|
|
|
|
|
Private m_dThickness As Double
|
|
|
|
|
Public Property dThickness As Double
|
|
|
|
|
Public Property dThickness As String
|
|
|
|
|
Get
|
|
|
|
|
Return m_dThickness
|
|
|
|
|
Return DoubleToString(m_dThickness, 2)
|
|
|
|
|
End Get
|
|
|
|
|
Set(value As Double)
|
|
|
|
|
m_dThickness = value
|
|
|
|
|
Set(value As String)
|
|
|
|
|
Dim dValue As Double = 0
|
|
|
|
|
If Not StringToDouble(value, dValue) Then
|
|
|
|
|
MessageBox.Show("Dimensione non valida!", "Errore!", MessageBoxButton.OK, MessageBoxImage.Error)
|
|
|
|
|
NotifyPropertyChanged(NameOf(dThickness))
|
|
|
|
|
Return
|
|
|
|
|
End If
|
|
|
|
|
' verifico se file ddf o ddt
|
|
|
|
|
Dim sExtension As String = Path.GetExtension(m_sDDFName)
|
|
|
|
|
If sExtension.ToLower() = ".ddf" Then
|
|
|
|
|
m_dThickness = dValue
|
|
|
|
|
Return
|
|
|
|
|
ElseIf sExtension.ToLower() = ".ddt" Then
|
|
|
|
|
If CreateDdfFromDdt(m_nId, m_sDDFName, m_dWidth, m_dHeight, dValue) Then
|
|
|
|
|
m_dThickness = dValue
|
|
|
|
|
' riporto indietro stato a da verificare
|
|
|
|
|
Me.m_nState = DoorStates.LOADED_FROM_CSV
|
|
|
|
|
NotifyPropertyChanged(NameOf(nState))
|
|
|
|
|
Else
|
|
|
|
|
NotifyPropertyChanged(NameOf(dThickness))
|
|
|
|
|
Return
|
|
|
|
|
End If
|
|
|
|
|
End If
|
|
|
|
|
End Set
|
|
|
|
|
End Property
|
|
|
|
|
|
|
|
|
@@ -856,8 +1008,9 @@ Public Class Door
|
|
|
|
|
Return m_nState
|
|
|
|
|
End Get
|
|
|
|
|
End Property
|
|
|
|
|
Friend Sub SetState(value As DoorStates, Optional bUpdate As Boolean = True)
|
|
|
|
|
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))
|
|
|
|
@@ -1045,6 +1198,49 @@ Public Class Door
|
|
|
|
|
m_dtUnloadTime = JsonDoor.dtUnloadTime
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Friend Shared Function CreateDdfFromDdt(nId As Integer, sDDFName As String, dWidth As Double, dHeight As Double, dThickness As Double) As Boolean
|
|
|
|
|
Dim sDoorCreatorExePath As String = ""
|
|
|
|
|
GetPluginPrivateProfileString(S_GENERAL, K_DOORCREATOREXEPATH, "", sDoorCreatorExePath)
|
|
|
|
|
Dim sDDTDirPath As String = ""
|
|
|
|
|
GetPluginPrivateProfileString(S_GENERAL, K_DDTDIR, "", sDDTDirPath)
|
|
|
|
|
Dim sGenDDFDirPath As String = ""
|
|
|
|
|
GetPluginPrivateProfileString(S_GENERAL, K_GENDDFDIR, "", sGenDDFDirPath)
|
|
|
|
|
Dim sDDTFilePath As String = sDDTDirPath & "\" & sDDFName
|
|
|
|
|
If String.IsNullOrWhiteSpace(sDoorCreatorExePath) OrElse Not File.Exists(sDoorCreatorExePath) Then
|
|
|
|
|
MessageBox.Show("Path del programma di calcolo del ddf mancante o errata!", "Errore!", MessageBoxButton.OK, MessageBoxImage.Error)
|
|
|
|
|
Return False
|
|
|
|
|
ElseIf Not File.Exists(sDDTFilePath) Then
|
|
|
|
|
MessageBox.Show("Il nome inserito non corrisponde a nessun file nella cartella dei Ddt (" & sDDTDirPath & ") ", "File non trovato!", MessageBoxButton.OK, MessageBoxImage.Error)
|
|
|
|
|
Return False
|
|
|
|
|
End If
|
|
|
|
|
' creo il ddf
|
|
|
|
|
Dim sGenDDFFilePath As String = sGenDDFDirPath & "\" & If(Not String.IsNullOrWhiteSpace(Path.GetDirectoryName(sDDFName)), Path.GetDirectoryName(sDDFName) & "_", "") & Path.GetFileNameWithoutExtension(sDDFName) & "_" & nId & ".ddf"
|
|
|
|
|
Dim Proc As New Process()
|
|
|
|
|
Proc.StartInfo.FileName = """" & sDoorCreatorExePath & """"
|
|
|
|
|
Proc.StartInfo.RedirectStandardInput = False
|
|
|
|
|
Proc.StartInfo.RedirectStandardOutput = False
|
|
|
|
|
Proc.StartInfo.Arguments = """" & sDDTFilePath & ";" & DoubleToString(dWidth, 2) & ";" & DoubleToString(dHeight, 2) & ";" & DoubleToString(dThickness, 2) & ";" & sGenDDFFilePath & """"
|
|
|
|
|
Proc.StartInfo.UseShellExecute = False
|
|
|
|
|
Proc.StartInfo.CreateNoWindow = True
|
|
|
|
|
Dim ExecCounter = 0
|
|
|
|
|
If Proc.Start Then
|
|
|
|
|
While Not Proc.HasExited
|
|
|
|
|
If ExecCounter >= 30 Then
|
|
|
|
|
Proc.Kill()
|
|
|
|
|
Exit While
|
|
|
|
|
End If
|
|
|
|
|
Threading.Thread.Sleep(100)
|
|
|
|
|
ExecCounter += 1
|
|
|
|
|
End While
|
|
|
|
|
End If
|
|
|
|
|
' se file generato
|
|
|
|
|
If Not File.Exists(sGenDDFFilePath) Then
|
|
|
|
|
MessageBox.Show("Generazione file ddf fallita!", "Errore!", MessageBoxButton.OK, MessageBoxImage.Error)
|
|
|
|
|
Return False
|
|
|
|
|
End If
|
|
|
|
|
Return True
|
|
|
|
|
End Function
|
|
|
|
|
|
|
|
|
|
End Class
|
|
|
|
|
|
|
|
|
|
Public Class CustomerParameter
|
|
|
|
|