diff --git a/Effector.Plugin.FiveLakes/Constants/ConstIni.vb b/Effector.Plugin.FiveLakes/Constants/ConstIni.vb
index 881425d..fab97d5 100644
--- a/Effector.Plugin.FiveLakes/Constants/ConstIni.vb
+++ b/Effector.Plugin.FiveLakes/Constants/ConstIni.vb
@@ -17,6 +17,8 @@ Module ConstIni
Public Const S_GENERAL As String = "General"
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 S_CSV As String = "CSV"
Public Const K_DDFNAME As String = "DDFName"
@@ -24,12 +26,15 @@ 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_DELIMITER As String = "Delimiter"
Public Const S_DEBUG As String = "Debug"
Public Const K_VARIABLELIST As String = "VariableList"
Public Const K_VARIABLEONDRAW As String = "VariableOnDraw"
Public Const K_MACHINECOMMANDS As String = "MachineCommands"
Public Const K_DOORCIRCLIST As String = "DoorCircList"
+ Public Const K_DOORPRESENCE As String = "DoorPresence"
+ Public Const K_DOORINDEX As String = "DoorIndex"
Public Const S_NC As String = "NC"
Public Const K_NC_SIMULATE As String = "NcSimulate"
diff --git a/Effector.Plugin.FiveLakes/DoorListPage/DoorListPageV.xaml b/Effector.Plugin.FiveLakes/DoorListPage/DoorListPageV.xaml
index f762524..39f8532 100644
--- a/Effector.Plugin.FiveLakes/DoorListPage/DoorListPageV.xaml
+++ b/Effector.Plugin.FiveLakes/DoorListPage/DoorListPageV.xaml
@@ -54,9 +54,9 @@
-
+ Width="Auto"/>-->
@@ -94,5 +94,10 @@
Binding="{Binding sUnloadTime}"
Width="Auto"/>
+
+
+
diff --git a/Effector.Plugin.FiveLakes/DoorListPage/DoorListPageVM.vb b/Effector.Plugin.FiveLakes/DoorListPage/DoorListPageVM.vb
index 99c3ceb..cbff647 100644
--- a/Effector.Plugin.FiveLakes/DoorListPage/DoorListPageVM.vb
+++ b/Effector.Plugin.FiveLakes/DoorListPage/DoorListPageVM.vb
@@ -79,9 +79,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
@@ -91,9 +91,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
@@ -161,6 +161,27 @@ Public Class DoorListPageVM
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
+ 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")
End If
WriteBackup()
ArgumentsResult = m_ExecProcessManager.ArgumentsResultDequeue
@@ -180,6 +201,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
+
#End Region ' METHODS
#Region "COMMANDS"
@@ -208,7 +237,9 @@ Public Class DoorListPageVM
Dim sCSVPath As String = OpenFileDialog.FileName
Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(sCSVPath)
MyReader.TextFieldType = FileIO.FieldType.Delimited
- MyReader.SetDelimiters(";")
+ 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 = ""
@@ -299,16 +330,23 @@ Public Class DoorListPageVM
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)
+ 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
- m_ExecProcessManager.ArgumentsEnqueue(New ProcessArgs(Door.nId, sDDFFilePath))
+ 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
@@ -470,16 +508,19 @@ Public Class DoorListPageVM
End Property
Public Sub Produce()
- If IsNothing(SelDoor) OrElse SelDoor.nState = Door.DoorStates.SKIPPED OrElse
- SelDoor.nState = Door.DoorStates.VERIFICATION_FAILED OrElse
- SelDoor.nState >= Door.DoorStates.READY_FOR_PRODUCTION Then Return
+ 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(SelDoor)
- Dim SelectedDoor As Door = m_SelDoor
+ Dim nOldIndex As Integer = m_DoorList.IndexOf(DoorToProduce)
m_DoorList.Move(nOldIndex, nNewIndex)
- SelectedDoor.SetState(Door.DoorStates.READY_FOR_PRODUCTION)
- WriteBackup()
+ DoorToProduce.SetState(Door.DoorStates.READY_FOR_PRODUCTION, bWriteBackup)
End Sub
#End Region ' Produce
@@ -496,7 +537,11 @@ Public Class DoorListPageVM
End Property
Public Sub ProduceAll()
- If IsNothing(SelDoor) Then Return
+ 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
@@ -507,18 +552,14 @@ Public Class DoorListPageVM
Public ReadOnly Property ResetProductionQueue_Command As ICommand
Get
If m_cmdResetProductionQueue Is Nothing Then
- m_cmdResetProductionQueue = New Command(AddressOf ResetProductionQueue)
+ m_cmdResetProductionQueue = New Command(AddressOf ResetProductionQueueCmd)
End If
Return m_cmdResetProductionQueue
End Get
End Property
- 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
+ Public Sub ResetProductionQueueCmd()
+ ResetProductionQueue()
WriteBackup()
End Sub
@@ -552,7 +593,7 @@ Public Class DoorListPageVM
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
+ Dim sDDFFilePath As String = sDDFDirPath & "\" & Door.sDDFName & ".ddf"
m_ExecProcessManager.ArgumentsEnqueue(New ProcessArgs(Door.nId, sDDFFilePath))
End If
Next
@@ -583,8 +624,8 @@ Public Class Door
MACHINE_1_START = 33
MACHINE_1_END = 34
MACHINE_2_START = 35
- MACHINE_2_END = 35
- PRODUCED = 36
+ MACHINE_2_END = 36
+ PRODUCED = 37
SCRAP = 40
End Enum
@@ -669,9 +710,13 @@ 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 bUpdate Then NotifyPropertyChanged(NameOf(nState))
+ If bWriteBackup Then Map.refDoorListPageVM.WriteBackup()
+ If bUpdate Then
+ NotifyPropertyChanged(NameOf(nState))
+ NotifyPropertyChanged(NameOf(Background))
+ End If
End Sub
#Region "Statistics"
@@ -685,6 +730,8 @@ Public Class Door
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
@@ -797,6 +844,35 @@ Public Class Door
#End Region ' Statistics
+ Public ReadOnly Property Background As SolidColorBrush
+ Get
+ Select Case m_nState
+ Case DoorStates.LOADED_FROM_CSV
+ Return Brushes.White
+ 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
+ Case DoorStates.MACHINE_1_START
+ Return Brushes.DodgerBlue
+ Case DoorStates.MACHINE_1_END
+ Return Brushes.Yellow
+ Case DoorStates.MACHINE_2_START
+ Return Brushes.DodgerBlue
+ Case DoorStates.MACHINE_2_END, DoorStates.PRODUCED
+ Return Brushes.LightGray
+ 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
diff --git a/Effector.Plugin.FiveLakes/LUA/Lua_General.vb b/Effector.Plugin.FiveLakes/LUA/Lua_General.vb
index e7f3a3c..8b7879f 100644
--- a/Effector.Plugin.FiveLakes/LUA/Lua_General.vb
+++ b/Effector.Plugin.FiveLakes/LUA/Lua_General.vb
@@ -10,6 +10,7 @@ Public Module Lua_General
Friend func_PlgCheckExecProcessAsync As LuaFunction = AddressOf Lua_PlgCheckExecProcessAsync
Friend func_PlgGetNextDoor As LuaFunction = AddressOf Lua_PlgGetNextDoor
Friend func_PlgOpenRestartWnd As LuaFunction = AddressOf Lua_PlgOpenRestartWnd
+ Friend func_PlgMachineReset As LuaFunction = AddressOf Lua_PlgMachineReset
Private Function Lua_PlgGetNumberFromIni(ByVal p As IntPtr) As Integer
Dim state = Lua.FromIntPtr(p)
@@ -107,7 +108,8 @@ Public Module Lua_General
If Not IsNothing(NextDoor) Then
' restituisco il risultato
LuaSetParam(state, NextDoor.nId)
- LuaSetParam(state, NextDoor.sDDFName)
+ ' Dim sGenDDFName As String = Path.GetFileNameWithoutExtension(NextDoor.sDDFName) & "_" & NextDoor.nId & ".ddf"
+ LuaSetParam(state, NextDoor.sDDFName & "_" & NextDoor.nId)
Return 2
End If
Return 0
@@ -115,9 +117,25 @@ Public Module Lua_General
Private Function Lua_PlgOpenRestartWnd(ByVal p As IntPtr) As Integer
Dim state = Lua.FromIntPtr(p)
+ Dim nMachineIndex As Integer = 1
+ LuaGetParam(state, 1, nMachineIndex)
LuaClearStack(state)
- Dim RestartWnd As New RestartWndV(Application.Current.MainWindow, New RestartWndVM())
- RestartWnd.ShowDialog()
+ Dim RestartWnd As New RestartWndV(Application.Current.MainWindow, New RestartWndVM(nMachineIndex))
+ Dim bRes As Boolean = RestartWnd.ShowDialog()
+ If Not IsNothing(bRes) Then
+ ' restituisco il risultato
+ LuaSetParam(state, bRes)
+ Return 1
+ End If
+ Return 0
+ End Function
+
+ Private Function Lua_PlgMachineReset(ByVal p As IntPtr) As Integer
+ Dim state = Lua.FromIntPtr(p)
+ Dim nMachineIndex As Integer = 1
+ LuaGetParam(state, 1, nMachineIndex)
+ LuaClearStack(state)
+ Map.refDoorListPageVM.ResetProductionQueue()
Return 0
End Function
@@ -131,6 +149,7 @@ Public Module Lua_General
state.Register("PlgCheckExecProcessAsync", func_PlgCheckExecProcessAsync)
state.Register("PlgGetNextDoor", func_PlgGetNextDoor)
state.Register("PlgOpenRestartWnd", func_PlgOpenRestartWnd)
+ state.Register("PlgMachineReset", func_PlgMachineReset)
Return True
End Function
diff --git a/Effector.Plugin.FiveLakes/MachinePage/MachinePageV.xaml b/Effector.Plugin.FiveLakes/MachinePage/MachinePageV.xaml
index 3b2c546..401d6ab 100644
--- a/Effector.Plugin.FiveLakes/MachinePage/MachinePageV.xaml
+++ b/Effector.Plugin.FiveLakes/MachinePage/MachinePageV.xaml
@@ -14,6 +14,7 @@
+
@@ -767,42 +768,42 @@
+ Style="{Binding VariableList[0].sValue, Converter={StaticResource StringToStyleConverter}}">
+ Style="{Binding VariableList[1].sValue, Converter={StaticResource StringToStyleConverter}}">
+ Style="{Binding VariableList[2].sValue, Converter={StaticResource StringToStyleConverter}}">
+ Style="{Binding VariableList[3].sValue, Converter={StaticResource StringToStyleConverter}}">
+ Visibility="{Binding VariableList[24].sValue, Converter={StaticResource StringToVisibilityConverter}}"
+ Style="{Binding VariableList[24].sValue, Converter={StaticResource StringToStyleConverter}}">
+ Style="{Binding VariableList[25].sValue, Converter={StaticResource StringToStyleConverter}}">
@@ -810,25 +811,90 @@
+ Style="{Binding VariableList[26].sValue, Converter={StaticResource StringToStyleConverter}}">
+ Style="{Binding VariableList[27].sValue, Converter={StaticResource StringToStyleConverter}}">
+ Style="{Binding VariableList[28].sValue, Converter={StaticResource StringToStyleConverter}}">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
@@ -862,93 +925,48 @@
-
-
-
-
-
-
-
+
-
-
-
-
-
-
@@ -957,277 +975,163 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Effector.Plugin.FiveLakes/MachinePage/MachinePageVM.vb b/Effector.Plugin.FiveLakes/MachinePage/MachinePageVM.vb
index 69d5446..8b8aca7 100644
--- a/Effector.Plugin.FiveLakes/MachinePage/MachinePageVM.vb
+++ b/Effector.Plugin.FiveLakes/MachinePage/MachinePageVM.vb
@@ -207,7 +207,7 @@ Public Class MachinePageVM
End Select
Next
' se in simulazione
- If Map.refSupervisorFunction.PlgGetPrivateProfileInt(S_NC, K_NC_SIMULATE, 0) Then
+ If Map.refSupervisorFunction.PlgGetPrivateProfileInt(S_NC, K_NC_SIMULATE, 0) > 0 Then
' aggiorno stato porta in macchina da 1 a 2 se in stazione di lavorazione
For nMachineIndex = 1 To 2
Dim nMachineId As Integer = nMachineIndex
@@ -254,6 +254,8 @@ Public Class MachinePageVM
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".nCircIndex", nCircIndex)
Dim nDoorState As Integer = -1
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".nState", nDoorState)
+ Dim nDoorPosition As Integer = -1
+ LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".nDoorPosition", nDoorPosition)
Dim sDoorCode As String = ""
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".sDoorCode", sDoorCode)
Dim sDoorDescription As String = ""
@@ -278,7 +280,7 @@ Public Class MachinePageVM
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".nMachining2End", lMachining2End)
Dim lUnloadTime As Long = 0
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".nUnloadTime", lUnloadTime)
- m_LuaDoorList.Add(New LuaDoor(nId, nCircIndex, nDoorState, sDoorCode, sDoorDescription, sDDFName, sCSVName, sM1CNPath, sM2CNPath, lLoadTime, lMachining1Start, lMachining1End, lMachining2Start, lMachining2End, lUnloadTime))
+ m_LuaDoorList.Add(New LuaDoor(nId, nCircIndex, nDoorState, nDoorPosition, sDoorCode, sDoorDescription, sDDFName, sCSVName, sM1CNPath, sM2CNPath, lLoadTime, lMachining1Start, lMachining1End, lMachining2Start, lMachining2End, lUnloadTime))
If nId > 0 Then
' aggiorno dati in lista porte
Dim Door As Door = Map.refDoorListPageVM.DoorList.FirstOrDefault(Function(x) x.nId = nId)
@@ -297,7 +299,7 @@ Public Class MachinePageVM
Dim Var As Variable = m_VariableList(nVarIndex)
If nVarIndex >= 5 AndAlso nVarIndex <= 9 Then
Dim nId As Integer = -1
- If Var.nValue > 0 Then
+ If Var.nValue > 0 AndAlso Var.nValue <= 10 Then
m_DoorOnMachineArray(nVarIndex - 5) = m_LuaDoorList(Var.nValue - 1)
Else
m_DoorOnMachineArray(nVarIndex - 5) = Nothing
@@ -305,7 +307,7 @@ Public Class MachinePageVM
End If
If nVarIndex >= 30 AndAlso nVarIndex <= 33 Then
Dim nId As Integer = -1
- If Var.nValue > 0 Then
+ If Var.nValue > 0 AndAlso Var.nValue <= 10 Then
m_DoorOnMachineArray(nVarIndex - 25) = m_LuaDoorList(Var.nValue - 1)
Else
m_DoorOnMachineArray(nVarIndex - 25) = Nothing
@@ -416,10 +418,10 @@ Public Class MachinePageVM
If (MachineStateVar.nValue <> 2 AndAlso MachineStateVar.nValue <> 4) OrElse
Sent1Var.nValue <> 0 OrElse Sent2Var.nValue <> 0 Then Return
End If
- ' verifco se variabile tavolo di lavoro, che la macchina abbia finito di lavorare
+ ' verifco se variabile tavolo di lavoro, che la macchina abbia finito di lavorare o che sia a inizializzazione perche' ripartenza
If nVerifyFromVarAddress = 1362 Then
Dim MachineStateVar As Variable = VariableList.FirstOrDefault(Function(x) x.nMachine = nVerifyFromMachineIndex AndAlso x.sName = "@STATE")
- If MachineStateVar.nValue <> 3 AndAlso MachineStateVar.nValue <> 5 Then Return
+ If MachineStateVar.nValue <> 1 AndAlso MachineStateVar.nValue <> 3 AndAlso MachineStateVar.nValue <> 5 Then Return
End If
' verifico che stazione di destinazione non sia gia' occupata
Dim sToAndPresenceVariables As String() = sVariableToMoveArgs(1).Split("/"c)
@@ -603,7 +605,7 @@ Public Class MachinePageVM
Case 0
Return
Case 1
- If nStartStop = 1 AndAlso StartDoorPresence.dValue = 1 AndAlso Sent1.nValue = 1 Then
+ If nStartStop = 1 AndAlso (StartDoorPresence.dValue = 1 OrElse EndDoorPresence.dValue = 2) AndAlso Sent1.nValue = 1 Then
nState = 2
Map.refSupervisorFunction.ComWriteShortVar(Sent1.sIndex, 0, nMachineIndex)
Else Return
@@ -768,6 +770,13 @@ Public Class LuaDoor
End Get
End Property
+ Private m_nDoorPosition As Integer = 0
+ Public ReadOnly Property nDoorPosition As Integer
+ Get
+ Return m_nDoorPosition
+ End Get
+ End Property
+
Private m_sDoorCode As String = ""
Public ReadOnly Property sDoorCode As String
Get
@@ -852,11 +861,12 @@ Public Class LuaDoor
End Get
End Property
- Sub New(nId As Integer, nCircIndex As Integer, nState As Integer, sDoorCode As String, sDoorDescription As String, sDDFName As String, sCSVName As String,
+ Sub New(nId As Integer, nCircIndex As Integer, nState As Integer, nDoorPosition As Integer, sDoorCode As String, sDoorDescription As String, sDDFName As String, sCSVName As String,
sM1CNPath As String, sM2CNPath As String, lLoadTime As Long, lMachining1Start As Long, lMachining1End As Long, lMachining2Start As Long, lMachining2End As Long, lUnloadTime As Long)
m_nId = nId
m_nCircIndex = nCircIndex
m_nState = nState
+ m_nDoorPosition = nDoorPosition
m_sDoorCode = sDoorCode
m_sDoorDescription = sDoorDescription
m_sDDFName = sDDFName
@@ -1024,3 +1034,26 @@ Public Class DoorToVisibilityConverter
End Function
End Class
+
+Public Class StringToStyleConverter
+ Implements IValueConverter
+
+ Dim DoorStyle As Style = Application.Current.TryFindResource("Door")
+ Dim CutOutScrapStyle As Style = Application.Current.TryFindResource("CutOutScrap")
+
+ 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 String OrElse String.IsNullOrWhiteSpace(value) Then Return "Door"
+ Dim sValue As String = value
+ Dim sLowerValue As String = sValue.ToLower()
+ If sLowerValue = "true" Then Return "Door"
+ If sLowerValue = "false" Then Return "Door"
+ Dim nValue As Integer
+ If Not Integer.TryParse(sValue, nValue) Then Return "Door"
+ Return If(nValue = 4, CutOutScrapStyle, DoorStyle)
+ 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
diff --git a/Effector.Plugin.FiveLakes/ProcessManager/ProcessManagerV.xaml b/Effector.Plugin.FiveLakes/ProcessManager/ProcessManagerV.xaml
index 7e97755..d749df5 100644
--- a/Effector.Plugin.FiveLakes/ProcessManager/ProcessManagerV.xaml
+++ b/Effector.Plugin.FiveLakes/ProcessManager/ProcessManagerV.xaml
@@ -20,7 +20,7 @@
Text="ResultQueue: "/>
+ Text="{Binding ResultQueue}"/>
-
+
+
+
+
+
+
+
+
diff --git a/Effector.Plugin.FiveLakes/RestartWnd/RestartWndVM.vb b/Effector.Plugin.FiveLakes/RestartWnd/RestartWndVM.vb
index e0758bf..5fa12b8 100644
--- a/Effector.Plugin.FiveLakes/RestartWnd/RestartWndVM.vb
+++ b/Effector.Plugin.FiveLakes/RestartWnd/RestartWndVM.vb
@@ -1,15 +1,28 @@
Imports Newtonsoft.Json
+Imports Newtonsoft.Json.Linq
Imports System.Collections.ObjectModel
Imports System.Globalization
Imports System.IO
+Imports System.Reflection
Public Class RestartWndVM
Inherits VMBase
Friend Event m_CloseWindow(bDialogResult As Boolean)
- ' Definizione comandi
- Private m_cmdOk As ICommand
+ Private m_sTitle As String = ""
+ Public ReadOnly Property sTitle As String
+ Get
+ Return m_sTitle
+ End Get
+ End Property
+
+ Private m_nMachineIndex As Integer = 1
+ Public ReadOnly Property nMachineIndex As Integer
+ Get
+ Return m_nMachineIndex
+ End Get
+ End Property
Private m_RestartDoorList As ObservableCollection(Of RestartDoor)
Public ReadOnly Property RestartDoorList As ObservableCollection(Of RestartDoor)
@@ -45,9 +58,23 @@ Public Class RestartWndVM
End Get
End Property
+ ' Definizione comandi
+ Private m_cmdOk As ICommand
+ Private m_cmdEmpty As ICommand
+
#Region "CONSTRUCTOR"
- Sub New()
+ Sub New(nMachineIndex As Integer)
+ m_nMachineIndex = nMachineIndex
+ m_sTitle = "Machine " & m_nMachineIndex
+ If Map.refSupervisorFunction.PlgGetPrivateProfileInt(S_NC, K_NC_SIMULATE, 0) > 0 Then
+ For nIndex = 0 To 4
+ Dim dValue As Double = GetPluginPrivateProfileDouble(S_DEBUG, K_DOORPRESENCE & "M" & m_nMachineIndex & "P" & nIndex, 0)
+ WriteVariableValueToName(nMachineIndex, "@WP_PR_0" & nIndex.ToString(), dValue)
+ Dim nValue As Integer = GetPluginPrivateProfileDouble(S_DEBUG, K_DOORINDEX & "M" & m_nMachineIndex & "P" & nIndex, 0)
+ WriteVariableValueToName(nMachineIndex, "@DOORN_S" & nIndex.ToString(), nValue)
+ Next
+ End If
Dim sBackupFilePath As String = ""
GetPluginPrivateProfileString("General", "BackupDir", "", sBackupFilePath)
sBackupFilePath &= "\LuaBackup.json"
@@ -66,9 +93,12 @@ Public Class RestartWndVM
' leggo presenze porta
For nPositionIndex As Integer = 4 To 0 Step -1
- If GetVariableFromName(1, "@WP_PR_0" & nPositionIndex.ToString()).dValue <> 0 Then
+ Dim dWPValue As Double = 0
+ GetVariableValueFromName(nMachineIndex, "@WP_PR_0" & nPositionIndex.ToString(), dWPValue)
+ If dWPValue <> 0 Then
' verifico indice
- Dim nCircindex As Integer = GetVariableFromName(1, "@DOORN_S" & nPositionIndex.ToString()).nValue
+ Dim nCircindex As Integer = 0
+ GetVariableValueFromName(nMachineIndex, "@DOORN_S" & nPositionIndex.ToString(), nCircindex)
If nCircindex <> 0 Then
m_DoorOnMachineArray(nPositionIndex) = New RestartDoor(JsonLuaDoorList(nCircindex - 1))
End If
@@ -109,9 +139,38 @@ Public Class RestartWndVM
#Region "METHODS"
- Private Function GetVariableFromName(nMachIndex As Integer, sName As String) As Variable
- Return Map.refMachinePageVM.VariableList.FirstOrDefault(Function(x) x.nMachine = nMachIndex AndAlso x.sName = sName)
+ Public Shared Function GetVariableValueFromName(nMachIndex As Integer, sName As String, ByRef nValue As Integer) As Boolean
+ Dim Variable As Variable = Map.refMachinePageVM.VariableList.FirstOrDefault(Function(x) x.nMachine = nMachIndex AndAlso x.sName = sName)
+ If IsNothing(Variable) Then Return False
+ Dim nIndex As Integer = 0
+ If Not Integer.TryParse(Variable.sIndex, nIndex) Then Return False
+ Return Map.refSupervisorFunction.ComReadShortVar(nIndex, nValue, nMachIndex)
End Function
+
+ Public Shared Function GetVariableValueFromName(nMachIndex As Integer, sName As String, ByRef dValue As Double) As Boolean
+ Dim Variable As Variable = Map.refMachinePageVM.VariableList.FirstOrDefault(Function(x) x.nMachine = nMachIndex AndAlso x.sName = sName)
+ If IsNothing(Variable) Then Return False
+ Dim nIndex As Integer = 0
+ If Not Integer.TryParse(Variable.sIndex, nIndex) Then Return False
+ Return Map.refSupervisorFunction.ComReadDoubleVar(nIndex, dValue, nMachIndex)
+ End Function
+
+ Public Shared Function WriteVariableValueToName(nMachIndex As Integer, sName As String, nValue As Integer) As Boolean
+ Dim Variable As Variable = Map.refMachinePageVM.VariableList.FirstOrDefault(Function(x) x.nMachine = nMachIndex AndAlso x.sName = sName)
+ If IsNothing(Variable) Then Return False
+ Dim nIndex As Integer = 0
+ If Not Integer.TryParse(Variable.sIndex, nIndex) Then Return False
+ Return Map.refSupervisorFunction.ComWriteShortVar(nIndex, nValue, nMachIndex)
+ End Function
+
+ Public Shared Function WriteVariableValueToName(nMachIndex As Integer, sName As String, dValue As Double) As Boolean
+ Dim Variable As Variable = Map.refMachinePageVM.VariableList.FirstOrDefault(Function(x) x.nMachine = nMachIndex AndAlso x.sName = sName)
+ If IsNothing(Variable) Then Return False
+ Dim nIndex As Integer = 0
+ If Not Integer.TryParse(Variable.sIndex, nIndex) Then Return False
+ Return Map.refSupervisorFunction.ComWriteDoubleVar(nIndex, dValue, nMachIndex)
+ End Function
+
#End Region ' METHODS
#Region "COMMANDS"
@@ -133,6 +192,25 @@ Public Class RestartWndVM
#End Region ' Ok
+#Region "Empty"
+
+ Public ReadOnly Property Empty_Command As ICommand
+ Get
+ If m_cmdEmpty Is Nothing Then
+ m_cmdEmpty = New Command(AddressOf Empty)
+ End If
+ Return m_cmdEmpty
+ End Get
+ End Property
+
+ Public Sub Empty()
+ Map.refDoorListPageVM.ResetProductionQueue()
+ Map.refDoorListPageVM.WriteBackup()
+ RaiseEvent m_CloseWindow(False)
+ End Sub
+
+#End Region ' Empty
+
#End Region ' COMMANDS
End Class
@@ -151,6 +229,25 @@ Public Class StateToVisibilityConverter
End Class
+Public Class VariableNameToVisibilityConverter
+ Implements IValueConverter
+
+ Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.Convert
+ If IsNothing(value) OrElse Not TypeOf value Is Integer Then Return Visibility.Collapsed
+ If IsNothing(parameter) OrElse Not TypeOf parameter Is String OrElse String.IsNullOrWhiteSpace(parameter) Then Return Visibility.Collapsed
+ Dim nMachineIndex As Integer = 0
+ If Not Integer.TryParse(value, nMachineIndex) Then Return Visibility.Collapsed
+ Dim dWPValue As Double = 0
+ RestartWndVM.GetVariableValueFromName(nMachineIndex, "@" & parameter, dWPValue)
+ Return If(dWPValue = 1 OrElse dWPValue = 2 OrElse dWPValue = 3, Visibility.Visible, Visibility.Collapsed)
+ 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 RestartDoor
Inherits VMBase
diff --git a/Effector.Plugin.FiveLakes/Utility/Dictionary.xaml b/Effector.Plugin.FiveLakes/Utility/Dictionary.xaml
index 399e2ff..f206425 100644
--- a/Effector.Plugin.FiveLakes/Utility/Dictionary.xaml
+++ b/Effector.Plugin.FiveLakes/Utility/Dictionary.xaml
@@ -76,6 +76,11 @@
+