- aggiunti backup dir e resources dir

- aggiunti flag di debug per nascondere grafica di debug
- aggiunti bottoni per verificare porte e resettare coda di produzione
- aggiunto stato di produzione e tempi a lista porte
- aggiunto stato lua a plugin
- aggiunta gestione tabella di tabella in alcune funzioni lua
- aggiunte funzioni che gestiscono esecuzione sincrona ed asincrona dell' eseguibile
- migliorato mainmenu ora funzionante
- aggiunta pagina statistiche
- aggiunto in pagina macchina disegno macchina con variabili di debug e lista circolare porte
This commit is contained in:
Emmanuele Sassi
2024-09-03 11:19:57 +02:00
parent 296e18704e
commit 7f031691bb
18 changed files with 2152 additions and 192 deletions
@@ -15,6 +15,8 @@ Module ConstIni
Public Const INI_FILE_NAME As String = "Supervisor.Plugin.FiveLakes.ini"
Public Const S_GENERAL As String = "General"
Public Const K_BACKUPDIR As String = "BackupDir"
Public Const K_RESOURCESDIR As String = "ResourcesDir"
Public Const S_CSV As String = "CSV"
Public Const K_DDFNAME As String = "DDFName"
@@ -23,4 +25,10 @@ Module ConstIni
Public Const K_WIDTH As String = "Width"
Public Const K_THICKNESS As String = "Thickness"
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"
End Module
@@ -1,7 +1,6 @@
<Grid x:Class="DoorListPageV"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Background="Yellow">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="1*"/>
@@ -9,7 +8,8 @@
<StackPanel Orientation="Horizontal">
<Button Content="CSV"
ToolTip="Open CSV file"
Command="{Binding OpenCSV_Command}"/>
Command="{Binding OpenCSV_Command}"
IsEnabled="{Binding bExecButton_IsEnabled}"/>
<Button Content="Skip Door"
ToolTip="Skip Door"
Command="{Binding SkipDoor_Command}"/>
@@ -31,9 +31,13 @@
<Button Content="Produce All"
ToolTip="Send all to production"
Command="{Binding ProduceAll_Command}"/>
<Button Content="Refresh"
ToolTip="Send all to production"
Command="{Binding Refresh_Command}"/>
<Button Content="Reset Production Queue"
ToolTip="Take all the door ready for production back to Verify state"
Command="{Binding ResetProductionQueue_Command}"/>
<Button Content="Verify"
ToolTip="Verify all the doors that are in state Not Verified"
Command="{Binding Verify_Command}"
IsEnabled="{Binding bExecButton_IsEnabled}"/>
</StackPanel>
<DataGrid Grid.Row="1"
ItemsSource="{Binding DoorList}"
@@ -67,6 +71,27 @@
<DataGridTextColumn Header="Csv"
Binding="{Binding sCSVName}"
Width="Auto"/>
<DataGridTextColumn Header="Production State"
Binding="{Binding nProdState}"
Width="Auto"/>
<DataGridTextColumn Header="Load Time"
Binding="{Binding sLoadTime}"
Width="Auto"/>
<DataGridTextColumn Header="Machining 1 Start"
Binding="{Binding sMachining1Start}"
Width="Auto"/>
<DataGridTextColumn Header="Machining 1 End"
Binding="{Binding sMachining1End}"
Width="Auto"/>
<DataGridTextColumn Header="Machining 2 Start"
Binding="{Binding sMachining2Start}"
Width="Auto"/>
<DataGridTextColumn Header="Machining 2 End"
Binding="{Binding sMachining2End}"
Width="Auto"/>
<DataGridTextColumn Header="Unload Time"
Binding="{Binding sUnloadTime}"
Width="Auto"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
@@ -27,6 +27,16 @@ Public Class DoorListPageVM
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
@@ -40,7 +50,8 @@ Public Class DoorListPageVM
Private m_cmdDeleteAll As ICommand
Private m_cmdProduce As ICommand
Private m_cmdProduceAll As ICommand
Private m_cmdRefresh As ICommand
Private m_cmdResetProductionQueue As ICommand
Private m_cmdVerify As ICommand
#Region "CONSTRUCTOR"
@@ -73,6 +84,18 @@ Public Class DoorListPageVM
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 sDDFDirPath As String = ""
GetPluginPrivateProfileString(S_GENERAL, "DDFDir", "", sDDFDirPath)
Dim sDDFFilePath As String = sDDFDirPath & "\" & 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)
@@ -112,7 +135,7 @@ Public Class DoorListPageVM
m_bWritingBackup = True
m_nBackupindex = m_nModifyIndex
Dim sBackupDirPath As String = ""
GetPluginPrivateProfileString(S_GENERAL, "BackupDir", "", sBackupDirPath)
GetPluginPrivateProfileString(S_GENERAL, K_BACKUPDIR, "", sBackupDirPath)
Dim sBackupFilePath As String = sBackupDirPath & "\Backup.json"
Write(sBackupFilePath)
m_bWritingBackup = False
@@ -146,7 +169,8 @@ Public Class DoorListPageVM
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
NextDoor.SetState(Door.DoorStates.SENT_TO_PRODUCTION)
NextDoor.SetState(Door.DoorStates.ON_LOAD_STATION)
WriteBackup()
End If
Return NextDoor
End Function
@@ -284,6 +308,7 @@ Public Class DoorListPageVM
Next
If bStartExecProcessManager OrElse m_ExecProcessManager.ExecutionThreadStatus = ExecProcessManager.ExecutionThreadStatuses.STOPPED Then
m_ExecProcessManager.StartExecutionThread()
SetExecButtonIsEnabled(False)
End If
End If
WriteBackup()
@@ -291,6 +316,7 @@ Public Class DoorListPageVM
Public Sub ExecProcessManager_AllArgsProcessed()
m_ExecProcessManager.StopExecutionThread()
SetExecButtonIsEnabled(True)
End Sub
Public Sub ExecProcessManager_PostProcess(ProcessArgsResult As ProcessArgsResult)
@@ -472,24 +498,68 @@ Public Class DoorListPageVM
#End Region ' ProduceAll
#Region "Refresh"
#Region "ResetProductionQueue"
Public ReadOnly Property Refresh_Command As ICommand
Public ReadOnly Property ResetProductionQueue_Command As ICommand
Get
If m_cmdRefresh Is Nothing Then
m_cmdRefresh = New Command(AddressOf Refresh)
If m_cmdResetProductionQueue Is Nothing Then
m_cmdResetProductionQueue = New Command(AddressOf ResetProductionQueue)
End If
Return m_cmdRefresh
Return m_cmdResetProductionQueue
End Get
End Property
Public Sub Refresh()
m_SelDoor.SetState(Door.DoorStates.READY_FOR_PRODUCTION)
'RefreshGraphicsTimer_Tick(Nothing, Nothing)
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
WriteBackup()
End Sub
#End Region ' Refresh
#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 Then
Dim sDDFFilePath As String = sDDFDirPath & "\" & Door.sDDFName
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
@@ -505,12 +575,27 @@ Public Class Door
VERIFICATION_FAILED = 11
SKIPPED = 20
READY_FOR_PRODUCTION = 30
SENT_TO_PRODUCTION = 31
IN_PRODUCTION = 32
PRODUCED = 32
ON_LOAD_STATION = 31
MACHINE_1_START = 33
MACHINE_1_END = 34
MACHINE_2_START = 35
MACHINE_2_END = 35
PRODUCED = 36
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
@@ -585,6 +670,129 @@ Public Class Door
If bUpdate Then NotifyPropertyChanged(NameOf(nState))
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.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
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
@@ -612,6 +820,13 @@ Public Class Door
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
+10 -2
View File
@@ -2,9 +2,13 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Supervisor.Plugin.FiveLakes"
DataContext="{StaticResource FiveLakesUIVM}"
Background="Red">
DataContext="{StaticResource FiveLakesUIVM}">
<TabControl SelectedIndex="{Binding SelPage}">
<TabControl.ItemContainerStyle>
<Style TargetType="TabItem">
<Setter Property="Visibility" Value="Collapsed" />
</Style>
</TabControl.ItemContainerStyle>
<TabItem Name="DoorList"
Header="DoorList">
<local:DoorListPageV DataContext="{StaticResource DoorListVM}"/>
@@ -13,6 +17,10 @@
Header="Machine">
<local:MachinePageV DataContext="{StaticResource MachinePageVM}"/>
</TabItem>
<TabItem Name="Statistics"
Header="Statistics">
<local:StatisticsPageV DataContext="{StaticResource StatisticsPageVM}"/>
</TabItem>
</TabControl>
<!--<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
+20 -1
View File
@@ -4,11 +4,31 @@ Imports Supervisor.Plugin.Interface
Public Class FiveLakesUIVM
Inherits VMBase
Public Enum Pages As Integer
DOOR_LIST = 0
MACHINE_STATUS = 1
STATISTICS = 2
End Enum
Private m_sDataRoot As String
Private m_sConfigDir As String
Private m_sIniFile As String
Private m_sResourcesRoot As String
Private m_SelPage As Pages
Public Property SelPage As Integer
Get
Return m_SelPage
End Get
Set(value As Integer)
m_SelPage = value
End Set
End Property
Friend Sub SetSelPage(nPage As Pages)
m_SelPage = nPage
NotifyPropertyChanged(NameOf(SelPage))
End Sub
Private m_TextTest As String
Public ReadOnly Property TextTest As String
Get
@@ -35,7 +55,6 @@ Public Class FiveLakesUIVM
IniFile.SetIniFile(m_sConfigDir & "\" & INI_FILE_NAME)
' Impostazione path resources dir
m_sResourcesRoot = m_sDataRoot & "\" & RES_DIR
End Sub
End Class
@@ -10,6 +10,7 @@ Public Class LuaManager
Private state As Lua
Public Function PlgInit(state As Object) As Boolean Implements IPluginLuaManager.PlgInit
SetState(state)
Return LuaInstallGeneral(state)
End Function
+334 -11
View File
@@ -2,6 +2,11 @@
Public Module Lua_Aux
Private m_State As Lua
Friend Sub SetState(state As Lua)
m_State = state
End Sub
Friend Function LuaClearStack(state As Lua)
Dim nIndex As Integer = state.GetTop()
If nIndex > 0 Then
@@ -24,6 +29,13 @@ Public Module Lua_Aux
Return True
End Function
Friend Function LuaCheckParam(state As Lua, nIndex As Integer, ByRef lValue As Long)
If Not LuaGetParam(state, nIndex, lValue) Then
Return state.Error(" Invalid Parameter # " & nIndex)
End If
Return True
End Function
Friend Function LuaCheckParam(state As Lua, nIndex As Integer, ByRef dValue As Double)
If Not LuaGetParam(state, nIndex, dValue) Then
Return state.Error(" Invalid Parameter # " & nIndex)
@@ -50,6 +62,12 @@ Public Module Lua_Aux
Return True
End Function
Friend Function LuaGetParam(state As Lua, nIndex As Integer, ByRef lValue As Long) As Boolean
If Not state.IsNumber(nIndex) Then Return False
lValue = state.ToInteger(nIndex)
Return True
End Function
Friend Function LuaGetParam(state As Lua, nIndex As Integer, ByRef dValue As Double) As Boolean
If Not state.IsNumber(nIndex) Then Return False
dValue = state.ToNumber(nIndex)
@@ -89,6 +107,15 @@ Public Module Lua_Aux
Return True
End Function
Friend Function LuaSetParam(state As Lua, ByRef lValue As Long) As Boolean
Try
state.PushInteger(lValue)
Catch ex As Exception
Return False
End Try
Return True
End Function
Friend Function LuaSetParam(state As Lua, ByRef dValue As Double) As Boolean
Try
state.PushNumber(dValue)
@@ -123,6 +150,14 @@ Public Module Lua_Aux
Return bResult
End Function
Friend Function LuaGetTabFieldParam(state As Lua, nIndex As Integer, sVarName As String, ByRef lValue As Long) As Boolean
If Not state.IsTable(nIndex) Then Return False
state.GetField(nIndex, sVarName)
Dim bResult As Boolean = LuaGetParam(state, -1, lValue)
state.Pop(1)
Return bResult
End Function
Friend Function LuaGetTabFieldParam(state As Lua, nIndex As Integer, sVarName As String, ByRef dValue As Double) As Boolean
If Not state.IsTable(nIndex) Then Return False
state.GetField(nIndex, sVarName)
@@ -147,13 +182,47 @@ Public Module Lua_Aux
state.Pop(1)
Return bResult
Else
Dim sTableName As String = "", sVarName As String = ""
Dim sTableName As String = ""
Dim sParams() As String = sName.Split("."c)
sTableName = sParams(0)
sVarName = sParams(1)
state.GetGlobal(sTableName)
For nParamIndex As Integer = 1 To sParams.Count - 2
Dim nTableIndex As Integer = -1
If Integer.TryParse(sParams(nParamIndex), nTableIndex) Then
state.RawGetInteger(-1, nTableIndex)
Else
state.GetField(-1, sParams(nParamIndex))
End If
Next
Dim sVarName As String = sParams(sParams.Count - 1)
Dim bResult As Boolean = LuaGetTabFieldParam(state, -1, sVarName, bValue)
state.Pop(1)
state.Pop(sParams.Count - 1)
Return bResult
End If
End Function
Friend Function LuaGetGlobVar(ByRef sName As String, ByRef bValue As Boolean) As Boolean
' se variabile standard
If Not sName.Contains("."c) Then
m_State.GetGlobal(sName)
Dim bResult As Boolean = LuaGetParam(m_State, -1, bValue)
m_State.Pop(1)
Return bResult
Else
Dim sTableName As String = ""
Dim sParams() As String = sName.Split("."c)
sTableName = sParams(0)
m_State.GetGlobal(sTableName)
For nParamIndex As Integer = 1 To sParams.Count - 2
Dim nTableIndex As Integer = -1
If Integer.TryParse(sParams(nParamIndex), nTableIndex) Then
m_State.RawGetInteger(-1, nTableIndex)
Else
m_State.GetField(-1, sParams(nParamIndex))
End If
Next
Dim sVarName As String = sParams(sParams.Count - 1)
Dim bResult As Boolean = LuaGetTabFieldParam(m_State, -1, sVarName, bValue)
m_State.Pop(sParams.Count - 1)
Return bResult
End If
End Function
@@ -166,14 +235,101 @@ Public Module Lua_Aux
state.Pop(1)
Return bResult
Else
Dim sTableName As String = "", sVarName As String = ""
Dim sTableName As String = ""
Dim sParams() As String = sName.Split("."c)
sTableName = sParams(0)
sVarName = sParams(1)
state.GetGlobal(sTableName)
For nParamIndex As Integer = 1 To sParams.Count - 2
Dim nTableIndex As Integer = -1
If Integer.TryParse(sParams(nParamIndex), nTableIndex) Then
state.RawGetInteger(-1, nTableIndex)
Else
state.GetField(-1, sParams(nParamIndex))
End If
Next
Dim sVarName As String = sParams(sParams.Count - 1)
Dim bResult As Boolean = LuaGetTabFieldParam(state, -1, sVarName, nValue)
state.Pop(sParams.Count - 1)
Return bResult
End If
End Function
Friend Function LuaGetGlobVar(ByRef sName As String, ByRef nValue As Integer) As Boolean
' se variabile standard
If Not sName.Contains("."c) Then
m_State.GetGlobal(sName)
Dim bResult As Boolean = LuaGetParam(m_State, -1, nValue)
m_State.Pop(1)
Return bResult
Else
Dim sTableName As String = ""
Dim sParams() As String = sName.Split("."c)
sTableName = sParams(0)
m_State.GetGlobal(sTableName)
For nParamIndex As Integer = 1 To sParams.Count - 2
Dim nTableIndex As Integer = -1
If Integer.TryParse(sParams(nParamIndex), nTableIndex) Then
m_State.RawGetInteger(-1, nTableIndex)
Else
m_State.GetField(-1, sParams(nParamIndex))
End If
Next
Dim sVarName As String = sParams(sParams.Count - 1)
Dim bResult As Boolean = LuaGetTabFieldParam(m_State, -1, sVarName, nValue)
m_State.Pop(sParams.Count - 1)
Return bResult
End If
End Function
Friend Function LuaGetGlobVar(state As Lua, ByRef sName As String, ByRef lValue As Long) As Boolean
' se variabile standard
If Not sName.Contains("."c) Then
state.GetGlobal(sName)
Dim bResult As Boolean = LuaGetParam(state, -1, lValue)
state.Pop(1)
Return bResult
Else
Dim sTableName As String = ""
Dim sParams() As String = sName.Split("."c)
sTableName = sParams(0)
state.GetGlobal(sTableName)
For nParamIndex As Integer = 1 To sParams.Count - 2
Dim nTableIndex As Integer = -1
If Integer.TryParse(sParams(nParamIndex), nTableIndex) Then
state.RawGetInteger(-1, nTableIndex)
Else
state.GetField(-1, sParams(nParamIndex))
End If
Next
Dim sVarName As String = sParams(sParams.Count - 1)
Dim bResult As Boolean = LuaGetTabFieldParam(state, -1, sVarName, lValue)
state.Pop(sParams.Count - 1)
Return bResult
End If
End Function
Friend Function LuaGetGlobVar(ByRef sName As String, ByRef lValue As Long) As Boolean
' se variabile standard
If Not sName.Contains("."c) Then
m_State.GetGlobal(sName)
Dim bResult As Boolean = LuaGetParam(m_State, -1, lValue)
m_State.Pop(1)
Return bResult
Else
Dim sTableName As String = ""
Dim sParams() As String = sName.Split("."c)
sTableName = sParams(0)
m_State.GetGlobal(sTableName)
For nParamIndex As Integer = 1 To sParams.Count - 2
Dim nTableIndex As Integer = -1
If Integer.TryParse(sParams(nParamIndex), nTableIndex) Then
m_State.RawGetInteger(-1, nTableIndex)
Else
m_State.GetField(-1, sParams(nParamIndex))
End If
Next
Dim sVarName As String = sParams(sParams.Count - 1)
Dim bResult As Boolean = LuaGetTabFieldParam(m_State, -1, sVarName, lValue)
m_State.Pop(sParams.Count - 1)
Return bResult
End If
End Function
@@ -185,13 +341,47 @@ Public Module Lua_Aux
state.Pop(1)
Return bResult
Else
Dim sTableName As String = "", sVarName As String = ""
Dim sTableName As String = ""
Dim sParams() As String = sName.Split("."c)
sTableName = sParams(0)
sVarName = sParams(1)
state.GetGlobal(sTableName)
For nParamIndex As Integer = 1 To sParams.Count - 2
Dim nTableIndex As Integer = -1
If Integer.TryParse(sParams(nParamIndex), nTableIndex) Then
state.RawGetInteger(-1, nTableIndex)
Else
state.GetField(-1, sParams(nParamIndex))
End If
Next
Dim sVarName As String = sParams(sParams.Count - 1)
Dim bResult As Boolean = LuaGetTabFieldParam(state, -1, sVarName, dValue)
state.Pop(1)
state.Pop(sParams.Count - 1)
Return bResult
End If
End Function
Friend Function LuaGetGlobVar(ByRef sName As String, ByRef dValue As Double) As Boolean
' se variabile standard
If Not sName.Contains("."c) Then
m_State.GetGlobal(sName)
Dim bResult As Boolean = LuaGetParam(m_State, -1, dValue)
m_State.Pop(1)
Return bResult
Else
Dim sTableName As String = ""
Dim sParams() As String = sName.Split("."c)
sTableName = sParams(0)
m_State.GetGlobal(sTableName)
For nParamIndex As Integer = 1 To sParams.Count - 2
Dim nTableIndex As Integer = -1
If Integer.TryParse(sParams(nParamIndex), nTableIndex) Then
m_State.RawGetInteger(-1, nTableIndex)
Else
m_State.GetField(-1, sParams(nParamIndex))
End If
Next
Dim sVarName As String = sParams(sParams.Count - 1)
Dim bResult As Boolean = LuaGetTabFieldParam(m_State, -1, sVarName, dValue)
m_State.Pop(sParams.Count - 1)
Return bResult
End If
End Function
@@ -204,13 +394,47 @@ Public Module Lua_Aux
state.Pop(1)
Return bResult
Else
Dim sTableName As String = "", sVarName As String = ""
Dim sTableName As String = ""
Dim sParams() As String = sName.Split("."c)
sTableName = sParams(0)
sVarName = sParams(1)
state.GetGlobal(sTableName)
For nParamIndex As Integer = 1 To sParams.Count - 2
Dim nTableIndex As Integer = -1
If Integer.TryParse(sParams(nParamIndex), nTableIndex) Then
state.RawGetInteger(-1, nTableIndex)
Else
state.GetField(-1, sParams(nParamIndex))
End If
Next
Dim sVarName As String = sParams(sParams.Count - 1)
Dim bResult As Boolean = LuaGetTabFieldParam(state, -1, sVarName, sValue)
state.Pop(1)
state.Pop(sParams.Count - 1)
Return bResult
End If
End Function
Friend Function LuaGetGlobVar(ByRef sName As String, ByRef sValue As String) As Boolean
' se variabile standard
If Not sName.Contains("."c) Then
m_State.GetGlobal(sName)
Dim bResult As Boolean = LuaGetParam(m_State, -1, sValue)
m_State.Pop(1)
Return bResult
Else
Dim sTableName As String = ""
Dim sParams() As String = sName.Split("."c)
sTableName = sParams(0)
m_State.GetGlobal(sTableName)
For nParamIndex As Integer = 1 To sParams.Count - 2
Dim nTableIndex As Integer = -1
If Integer.TryParse(sParams(nParamIndex), nTableIndex) Then
m_State.RawGetInteger(-1, nTableIndex)
Else
m_State.GetField(-1, sParams(nParamIndex))
End If
Next
Dim sVarName As String = sParams(sParams.Count - 1)
Dim bResult As Boolean = LuaGetTabFieldParam(m_State, -1, sVarName, sValue)
m_State.Pop(sParams.Count - 1)
Return bResult
End If
End Function
@@ -273,6 +497,24 @@ Public Module Lua_Aux
Return bResult
End If
End Function
Friend Function LuaSetGlobVar(ByRef sName As String, ByRef bValue As Boolean) As Boolean
' se variabile standard
If Not sName.Contains("."c) Then
If Not LuaSetParam(m_State, bValue) Then Return False
m_State.SetGlobal(sName)
Return True
' altrimenti campo di tabella
Else
Dim sTableName As String = "", sVarName As String = ""
Dim sParams() As String = sName.Split("."c)
sTableName = sParams(0)
sVarName = sParams(1)
m_State.GetGlobal(sTableName)
Dim bResult As Boolean = LuaSetTabFieldParam(m_State, -1, sVarName, bValue)
m_State.Pop(1)
Return bResult
End If
End Function
Friend Function LuaSetGlobVar(state As Lua, ByRef sName As String, ByRef nValue As Integer) As Boolean
' se variabile standard
@@ -292,6 +534,24 @@ Public Module Lua_Aux
Return bResult
End If
End Function
Friend Function LuaSetGlobVar(ByRef sName As String, ByRef nValue As Integer) As Boolean
' se variabile standard
If Not sName.Contains("."c) Then
If Not LuaSetParam(m_State, nValue) Then Return False
m_State.SetGlobal(sName)
Return True
' altrimenti campo di tabella
Else
Dim sTableName As String = "", sVarName As String = ""
Dim sParams() As String = sName.Split("."c)
sTableName = sParams(0)
sVarName = sParams(1)
m_State.GetGlobal(sTableName)
Dim bResult As Boolean = LuaSetTabFieldParam(m_State, -1, sVarName, nValue)
m_State.Pop(1)
Return bResult
End If
End Function
Friend Function LuaSetGlobVar(state As Lua, ByRef sName As String, ByRef dValue As Double) As Boolean
' se variabile standard
@@ -311,6 +571,24 @@ Public Module Lua_Aux
Return bResult
End If
End Function
Friend Function LuaSetGlobVar(ByRef sName As String, ByRef dValue As Double) As Boolean
' se variabile standard
If Not sName.Contains("."c) Then
If Not LuaSetParam(m_State, dValue) Then Return False
m_State.SetGlobal(sName)
Return True
' altrimenti campo di tabella
Else
Dim sTableName As String = "", sVarName As String = ""
Dim sParams() As String = sName.Split("."c)
sTableName = sParams(0)
sVarName = sParams(1)
m_State.GetGlobal(sTableName)
Dim bResult As Boolean = LuaSetTabFieldParam(m_State, -1, sVarName, dValue)
m_State.Pop(1)
Return bResult
End If
End Function
Friend Function LuaSetGlobVar(state As Lua, ByRef sName As String, ByRef sValue As String) As Boolean
' se variabile standard
@@ -330,6 +608,24 @@ Public Module Lua_Aux
Return bResult
End If
End Function
Friend Function LuaSetGlobVar(ByRef sName As String, ByRef sValue As String) As Boolean
' se variabile standard
If Not sName.Contains("."c) Then
If Not LuaSetParam(m_State, sValue) Then Return False
m_State.SetGlobal(sName)
Return True
' altrimenti campo di tabella
Else
Dim sTableName As String = "", sVarName As String = ""
Dim sParams() As String = sName.Split("."c)
sTableName = sParams(0)
sVarName = sParams(1)
m_State.GetGlobal(sTableName)
Dim bResult As Boolean = LuaSetTabFieldParam(m_State, -1, sVarName, sValue)
m_State.Pop(1)
Return bResult
End If
End Function
Friend Function LuaResetGlobVar(state As Lua, ByRef sName As String) As Boolean
' se variabile standard
@@ -349,6 +645,24 @@ Public Module Lua_Aux
Return bResult
End If
End Function
Friend Function LuaResetGlobVar(ByRef sName As String) As Boolean
' se variabile standard
If Not sName.Contains("."c) Then
If Not LuaSetParam(m_State) Then Return False
m_State.SetGlobal(sName)
Return True
' altrimenti campo di tabella
Else
Dim sTableName As String = "", sVarName As String = ""
Dim sParams() As String = sName.Split("."c)
sTableName = sParams(0)
sVarName = sParams(1)
m_State.GetGlobal(sTableName)
Dim bResult As Boolean = LuaSetTabFieldParam(m_State, -1, sVarName)
m_State.Pop(1)
Return bResult
End If
End Function
Friend Function LuaCreateGlobTable(state As Lua, ByRef sName As String) As Boolean
Try
@@ -359,5 +673,14 @@ Public Module Lua_Aux
End Try
Return True
End Function
Friend Function LuaCreateGlobTable(ByRef sName As String) As Boolean
Try
m_State.NewTable()
m_State.SetGlobal(sName)
Catch ex As Exception
Return False
End Try
Return True
End Function
End Module
+33 -2
View File
@@ -2,8 +2,10 @@ Imports KeraLua
Public Module Lua_General
Friend func_PlgGetNextDoor As LuaFunction = AddressOf Lua_PlgGetNextDoor
Friend func_PlgExecProcess As LuaFunction = AddressOf Lua_PlgExecProcess
Friend func_PlgExecProcessAsync As LuaFunction = AddressOf Lua_PlgExecProcessAsync
Friend func_PlgCheckExecProcessAsync As LuaFunction = AddressOf Lua_PlgCheckExecProcessAsync
Friend func_PlgGetNextDoor As LuaFunction = AddressOf Lua_PlgGetNextDoor
Private Function Lua_PlgExecProcess(ByVal p As IntPtr) As Integer
Dim state = Lua.FromIntPtr(p)
@@ -18,6 +20,33 @@ Public Module Lua_General
End If
End Function
Private Function Lua_PlgExecProcessAsync(ByVal p As IntPtr) As Integer
Dim state = Lua.FromIntPtr(p)
Dim sDDFName As String = ""
LuaCheckParam(state, 1, sDDFName)
LuaClearStack(state)
If Map.refDoorListPageVM.ExecCAMProcessAsync(sDDFName) Then
state.PushBoolean(True)
Return 1
Else
Return 0
End If
End Function
Private Function Lua_PlgCheckExecProcessAsync(ByVal p As IntPtr) As Integer
Dim state = Lua.FromIntPtr(p)
LuaClearStack(state)
Dim bHasExited As Boolean = False
Dim nExitCode As Integer = -1
If Map.refSupervisorFunction.PlgCheckExecProcessAsync(bHasExited, nExitCode) Then
state.PushBoolean(bHasExited)
state.PushInteger(nExitCode)
Return 2
Else
Return 0
End If
End Function
Private Function Lua_PlgGetNextDoor(ByVal p As IntPtr) As Integer
Dim state = Lua.FromIntPtr(p)
LuaClearStack(state)
@@ -33,8 +62,10 @@ Public Module Lua_General
Friend Function LuaInstallGeneral(state As Lua) As Boolean
If IsNothing(state) Then Return False
state.Register("PlgGetNextDoor", func_PlgGetNextDoor)
state.Register("PlgExecProcess", func_PlgExecProcess)
state.Register("PlgExecProcessAsync", func_PlgExecProcessAsync)
state.Register("PlgCheckExecProcessAsync", func_PlgCheckExecProcessAsync)
state.Register("PlgGetNextDoor", func_PlgGetNextDoor)
Return True
End Function
@@ -1,135 +1,664 @@
<Grid x:Class="MachinePageV"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Supervisor.Plugin.FiveLakes">
xmlns:local="clr-namespace:Supervisor.Plugin.FiveLakes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="950" d:DesignWidth="1600">
<Grid.Resources>
<local:StringToVisibilityConverter x:Key="StringToVisibilityConverter"/>
<local:StringToMachineStateConverter x:Key="StringToMachineStateConverter"/>
<local:StringToDDFCalcStateConverter x:Key="StringToDDFCalcStateConverter"/>
<local:StringToNewDoorStateConverter x:Key="StringToNewDoorStateConverter"/>
<local:StringToBooleanConverter x:Key="IntegerToBooleanConverter"/>
<local:StringToBackgroundConverter x:Key="StringToBackgroundConverter"/>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<!--<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>-->
<!--<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding MachinePos0}"/>
</Grid>-->
<ItemsControl ItemsSource="{Binding VariableList}">
<!--Lista variabili-->
<ItemsControl ItemsSource="{Binding VariableList}"
Visibility="{Binding VariableList_Visibility}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="150"/>
<ColumnDefinition Width="50"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0"
Text="{Binding sName}"/>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding sName}"/>
<TextBlock Text=" ("/>
<TextBlock Text="{Binding sIndex}"/>
<TextBlock Text=")"/>
</StackPanel>
<TextBlock Grid.Column="1"
Text="{Binding sIndex}"/>
<TextBlock Grid.Column="2"
Text="{Binding sValue}"/>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<Grid Grid.Column="1">
<Grid Grid.Column="1"
VerticalAlignment="Center">
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid>
<Grid
Visibility="{Binding MachineCommands_Visibility}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="20"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Column="0"
Grid.Row="0"
Text="DDF Calc State"/>
<TextBlock Grid.Column="2"
Grid.Row="0"
Text="{Binding nDDfCalcState, Converter={StaticResource StringToDDFCalcStateConverter}}"/>
<TextBlock Grid.Column="0"
Grid.Row="1"
Text="New Door State"/>
<TextBlock Grid.Column="2"
Grid.Row="1"
Text="{Binding nNewDoorState, Converter={StaticResource StringToNewDoorStateConverter}}"/>
</Grid>
<Grid Grid.Row="1"
VerticalAlignment="Center">
<Grid.Resources>
<Style x:Key="Table" TargetType="Border">
<Setter Property="BorderBrush" Value="Gray"/>
<Setter Property="BorderThickness" Value="5"/>
<Setter Property="Background" Value="LightGray"/>
<Setter Property="BorderThickness" Value="2"/>
</Style>
<Style x:Key="Door" TargetType="Border">
<Setter Property="BorderBrush" Value="SaddleBrown"/>
<Setter Property="BorderThickness" Value="5"/>
<Setter Property="Background" Value="SandyBrown"/>
<Setter Property="Height" Value="40"/>
<Setter Property="Width" Value="80"/>
</Style>
<Style x:Key="Advancement_Button" TargetType="Button">
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="TextBlock.TextAlignment" Value="Center"/>
</Style>
<Style x:Key="Sensor" TargetType="Ellipse">
<Setter Property="Height" Value="{Binding ActualWidth, RelativeSource={RelativeSource Self}}"/>
</Style>
<Style x:Key="MachDrawVar_TextBlock" TargetType="TextBlock">
<Setter Property="HorizontalAlignment" Value="Center"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
<Style x:Key="MachDrawVar_CheckBox" TargetType="CheckBox">
<Setter Property="IsHitTestVisible" Value="False"/>
<Setter Property="Focusable" Value="False"/>
<Setter Property="BorderThickness" Value="0"/>
</Style>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="2*"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="2*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="1">
<!--Gestori macchine-->
<Grid Grid.Column="1"
Grid.Row="1"
Visibility="{Binding MachineCommands_Visibility}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="3.8*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="3.5*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="3.7*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="3.5*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="3.8*"/>
</Grid.ColumnDefinitions>
<Border Style="{StaticResource Table}"/>
<Border Grid.Column="1"
Style="{StaticResource Table}"/>
<Border Grid.Column="2"
Style="{StaticResource Table}"/>
<Border Grid.Column="3"
Style="{StaticResource Table}"/>
<Border Grid.Column="4"
Style="{StaticResource Table}"/>
<Border Grid.Column="5"
Style="{StaticResource Table}"/>
<Border Grid.Column="6"
Style="{StaticResource Table}"/>
<Border Grid.Column="7"
Style="{StaticResource Table}"/>
<Border Grid.Column="8"
Style="{StaticResource Table}"/>
<Border Grid.Column="9"
Style="{StaticResource Table}"/>
<Grid Grid.Column="2">
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<TextBlock Text="{Binding VariableList[12].sValue, Converter={StaticResource StringToMachineStateConverter}}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
<Button Grid.Row="1"
Content="Initialize"
Command="{Binding WriteVariable_Command}"
CommandParameter="1,1,1352,1"
Style="{StaticResource Advancement_Button}"/>
<StackPanel Grid.Row="2"
Orientation="Horizontal"
HorizontalAlignment="Center">
<Button Content="Start&#x0d;&#x0a;Machining"
Command="{Binding ManageMachining_Command}"
CommandParameter="1,1"
Style="{StaticResource Advancement_Button}"/>
<Button Content="End&#x0d;&#x0a;Machining"
Command="{Binding ManageMachining_Command}"
CommandParameter="1,2"
Style="{StaticResource Advancement_Button}"/>
</StackPanel>
<Grid Grid.Row="3"
HorizontalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Column="0"
Grid.Row="0"
Text="Sent 1"/>
<CheckBox Grid.Column="1"
Grid.Row="0"
IsChecked="{Binding VariableList[10].sValue, Converter={StaticResource IntegerToBooleanConverter}}"
Style="{StaticResource MachDrawVar_CheckBox}"/>
<TextBlock Grid.Column="0"
Grid.Row="1"
Text="Sent 2"/>
<CheckBox Grid.Column="1"
Grid.Row="1"
IsChecked="{Binding VariableList[11].sValue, Converter={StaticResource IntegerToBooleanConverter}}"
Style="{StaticResource MachDrawVar_CheckBox}"/>
</Grid>
</Grid>
<Grid Grid.Column="6">
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<TextBlock Text="{Binding VariableList[36].sValue, Converter={StaticResource StringToMachineStateConverter}}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
<Button Grid.Row="1"
Content="Initialize"
Command="{Binding WriteVariable_Command}"
CommandParameter="2,1,1352,1"
Style="{StaticResource Advancement_Button}"/>
<StackPanel Grid.Row="2"
Orientation="Horizontal"
HorizontalAlignment="Center">
<Button Content="Start&#x0d;&#x0a;Machining"
Command="{Binding ManageMachining_Command}"
CommandParameter="2,1"
Style="{StaticResource Advancement_Button}"/>
<Button Content="End&#x0d;&#x0a;Machining"
Command="{Binding ManageMachining_Command}"
CommandParameter="2,2"
Style="{StaticResource Advancement_Button}"/>
</StackPanel>
<Grid Grid.Row="3"
HorizontalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Column="0"
Grid.Row="0"
Text="Sent 1"/>
<CheckBox Grid.Column="1"
Grid.Row="0"
IsChecked="{Binding VariableList[34].sValue, Converter={StaticResource IntegerToBooleanConverter}}"
Style="{StaticResource MachDrawVar_CheckBox}"/>
<TextBlock Grid.Column="0"
Grid.Row="1"
Text="Sent 2"/>
<CheckBox Grid.Column="1"
Grid.Row="1"
IsChecked="{Binding VariableList[35].sValue, Converter={StaticResource IntegerToBooleanConverter}}"
Style="{StaticResource MachDrawVar_CheckBox}"/>
</Grid>
</Grid>
</Grid>
<ItemsControl Grid.Row="1"
ItemsSource="{Binding DoorOnMachineList}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Canvas.Bottom="{Binding dBottomPosition}"
Canvas.Left="{Binding dLeftPosition}"
Style="{StaticResource Door}">
<TextBlock Text="{Binding nId}"
FontSize="20"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<!--<Canvas Grid.Row="1">
<Border Canvas.Top="30"
Canvas.Left="30"
<!--Bottoni avanzamento-->
<Grid Grid.Column="1"
Grid.Row="2"
Visibility="{Binding MachineCommands_Visibility}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3.8*"/>
<ColumnDefinition Width="18.7*"/>
<ColumnDefinition Width="3.8*"/>
</Grid.ColumnDefinitions>
<Button Content="Load Door&#x0d;&#x0a;On M1S0"
Command="{Binding WriteVariable_Command}"
CommandParameter="1,3,901.0,1;1,2,980,1"
Style="{StaticResource Advancement_Button}"/>
<Button Grid.Column="2"
Content="Unload Door&#x0d;&#x0a;From M2S4"
Command="{Binding WriteVariable_Command}"
CommandParameter="2,2,984,0;2,1,1364,0"
Style="{StaticResource Advancement_Button}"/>
</Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2.8*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="1.5*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="1.7*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="1.5*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="2.8*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="1"
Content="Go To&#x0d;&#x0a;M1S1"
Command="{Binding MoveVariable_Command}"
CommandParameter="1,1,1360/1,2,980;1,3,901.0->1,1,1361/1,2,981"
Style="{StaticResource Advancement_Button}"/>
<Button Grid.Column="2"
Content="Go To&#x0d;&#x0a;M1S2"
Command="{Binding MoveVariable_Command}"
CommandParameter="1,1,1361/1,2,981->1,1,1362/1,2,982"
Style="{StaticResource Advancement_Button}"/>
<Button Grid.Column="4"
Content="Go To&#x0d;&#x0a;M1S3"
Command="{Binding MoveVariable_Command}"
CommandParameter="1,1,1362/1,2,982->1,1,1363/1,2,983"
Style="{StaticResource Advancement_Button}"/>
<Button Grid.Column="5"
Content="Go To&#x0d;&#x0a;M1S4"
Command="{Binding MoveVariable_Command}"
CommandParameter="1,1,1363/1,2,983->1,1,1364;2,1,1360/1,2,984;2,2,980"
Style="{StaticResource Advancement_Button}"/>
<Button Grid.Column="7"
Content="Go To&#x0d;&#x0a;M2S1"
Command="{Binding MoveVariable_Command}"
CommandParameter="1,1,1364;2,1,1360/1,2,984;2,2,980->2,1,1361/2,2,981"
Style="{StaticResource Advancement_Button}"/>
<Button Grid.Column="8"
Content="Go To&#x0d;&#x0a;M2S2"
Command="{Binding MoveVariable_Command}"
CommandParameter="2,1,1361/2,2,981->2,1,1362/2,2,982"
Style="{StaticResource Advancement_Button}"/>
<Button Grid.Column="10"
Content="Go To&#x0d;&#x0a;M2S3"
Command="{Binding MoveVariable_Command}"
CommandParameter="2,1,1362/2,2,982->2,1,1363/2,2,983"
Style="{StaticResource Advancement_Button}"/>
<Button Grid.Column="11"
Content="Go To&#x0d;&#x0a;M2S4"
Command="{Binding MoveVariable_Command}"
CommandParameter="2,1,1363/2,2,983->2,1,1364/2,2,984"
Style="{StaticResource Advancement_Button}"/>
</Grid>
</Grid>
<!--Intestazioni-->
<Grid Grid.Row="3"
Visibility="{Binding VariableOnDraw_Visibility}">
<Grid.RowDefinitions>
<RowDefinition Height="0.7*"/>
<RowDefinition Height="0.3*"/>
<RowDefinition Height="0.7*"/>
<RowDefinition Height="0.6*"/>
<RowDefinition Height="0.3*"/>
<RowDefinition Height="0.6*"/>
<RowDefinition Height="0.7*"/>
<RowDefinition Height="0.3*"/>
<RowDefinition Height="0.7*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="1"
Text="Sensors"/>
<TextBlock Grid.Row="4"
Text="Door Index"/>
<TextBlock Grid.Row="7"
Text="Door Presence"/>
</Grid>
<!--Immagine macchina-->
<Image Grid.Column="1"
Grid.Row="3"
Source="{Binding sMachineImagePath}"
Stretch="Uniform"/>
<!--TextBox variabili-->
<Grid Grid.Column="1"
Grid.Row="3"
Visibility="{Binding VariableOnDraw_Visibility}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3.8*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="3.5*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="3.7*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="3.5*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="3.8*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1.7*"/>
<RowDefinition Height="1.5*"/>
<RowDefinition Height="1.7*"/>
</Grid.RowDefinitions>
<Border Grid.Column="0"
Grid.Row="1"
Style="{StaticResource Table}"/>
<TextBlock Grid.Column="0"
Grid.Row="1"
Text="{Binding VariableList[5].sValue}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
<TextBlock Grid.Column="0"
Grid.Row="2"
Text="{Binding VariableList[0].sValue}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
<Border Grid.Column="1"
Grid.Row="1"
Style="{StaticResource Table}"/>
<TextBlock Grid.Column="1"
Grid.Row="1"
Text="{Binding VariableList[6].sValue}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
<TextBlock Grid.Column="1"
Grid.Row="2"
Text="{Binding VariableList[1].sValue}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
<Border Grid.Column="2"
Grid.Row="1"
Style="{StaticResource Table}"/>
<TextBlock Grid.Column="2"
Grid.Row="1"
Text="{Binding VariableList[7].sValue}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
<TextBlock Grid.Column="2"
Grid.Row="2"
Text="{Binding VariableList[2].sValue}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
<Border Grid.Column="3"
Grid.Row="1"
Style="{StaticResource Table}"/>
<TextBlock Grid.Column="3"
Grid.Row="1"
Text="{Binding VariableList[8].sValue}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
<TextBlock Grid.Column="3"
Grid.Row="2"
Text="{Binding VariableList[3].sValue}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
<Border Grid.Column="4"
Grid.Row="1"
Style="{StaticResource Table}"/>
<StackPanel Grid.Column="4"
Grid.Row="1"
Orientation="Horizontal"
VerticalAlignment="Center"
HorizontalAlignment="Center">
<TextBlock Text="{Binding VariableList[9].sValue}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
<TextBlock Text="{Binding VariableList[29].sValue}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
</StackPanel>
<StackPanel Grid.Column="4"
Grid.Row="2"
Orientation="Horizontal"
VerticalAlignment="Center"
HorizontalAlignment="Center">
<TextBlock Text="{Binding VariableList[4].sValue}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
<TextBlock Text="{Binding VariableList[24].sValue}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
</StackPanel>
<Border Grid.Column="5"
Grid.Row="1"
Style="{StaticResource Table}"/>
<TextBlock Grid.Column="5"
Grid.Row="1"
Text="{Binding VariableList[30].sValue}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
<TextBlock Grid.Column="5"
Grid.Row="2"
Text="{Binding VariableList[25].sValue}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
<Border Grid.Column="6"
Grid.Row="1"
Style="{StaticResource Table}"/>
<TextBlock Grid.Column="6"
Grid.Row="1"
Text="{Binding VariableList[31].sValue}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
<TextBlock Grid.Column="6"
Grid.Row="2"
Text="{Binding VariableList[26].sValue}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
<Border Grid.Column="7"
Grid.Row="1"
Style="{StaticResource Table}"/>
<TextBlock Grid.Column="7"
Grid.Row="1"
Text="{Binding VariableList[32].sValue}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
<TextBlock Grid.Column="7"
Grid.Row="2"
Text="{Binding VariableList[27].sValue}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
<Border Grid.Column="8"
Grid.Row="1"
Style="{StaticResource Table}"/>
<TextBlock Grid.Column="8"
Grid.Row="1"
Text="{Binding VariableList[33].sValue}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
<TextBlock Grid.Column="8"
Grid.Row="2"
Text="{Binding VariableList[28].sValue}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
</Grid>
<!--Sensori-->
<Grid Grid.Column="1"
Grid.Row="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="0.2*"/>
<ColumnDefinition Width="0.6*"/>
<ColumnDefinition Width="0.9*"/>
<ColumnDefinition Width="0.2*"/>
<ColumnDefinition Width="0.9*"/>
<ColumnDefinition Width="0.8*"/>
<ColumnDefinition Width="0.2*"/>
<ColumnDefinition Width="0.3*"/>
<ColumnDefinition Width="0.2*"/>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="0.2*"/>
<ColumnDefinition Width="0.3*"/>
<ColumnDefinition Width="0.2*"/>
<ColumnDefinition Width="0.8*"/>
<ColumnDefinition Width="0.9*"/>
<ColumnDefinition Width="0.2*"/>
<ColumnDefinition Width="0.9*"/>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="0.2*"/>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="0.9*"/>
<ColumnDefinition Width="0.2*"/>
<ColumnDefinition Width="0.9*"/>
<ColumnDefinition Width="0.8*"/>
<ColumnDefinition Width="0.2*"/>
<ColumnDefinition Width="0.3*"/>
<ColumnDefinition Width="0.2*"/>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition Width="0.2*"/>
<ColumnDefinition Width="0.3*"/>
<ColumnDefinition Width="0.2*"/>
<ColumnDefinition Width="0.8*"/>
<ColumnDefinition Width="0.9*"/>
<ColumnDefinition Width="0.2*"/>
<ColumnDefinition Width="0.9*"/>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="0.2*"/>
<ColumnDefinition Width="0.6*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1.7*"/>
<RowDefinition Height="1.5*"/>
<RowDefinition Height="1.7*"/>
</Grid.RowDefinitions>
<Ellipse Grid.Column="1"
Fill="{Binding VariableList[16].sValue, Converter={StaticResource StringToBackgroundConverter}}"
Style="{StaticResource Sensor}"/>
<Ellipse Grid.Column="4"
Fill="{Binding VariableList[17].sValue, Converter={StaticResource StringToBackgroundConverter}}"
Style="{StaticResource Sensor}"/>
<Ellipse Grid.Column="7"
Fill="{Binding VariableList[18].sValue, Converter={StaticResource StringToBackgroundConverter}}"
Style="{StaticResource Sensor}"/>
<Ellipse Grid.Column="9"
Fill="{Binding VariableList[19].sValue, Converter={StaticResource StringToBackgroundConverter}}"
Style="{StaticResource Sensor}"/>
<Ellipse Grid.Column="11"
Fill="{Binding VariableList[20].sValue, Converter={StaticResource StringToBackgroundConverter}}"
Style="{StaticResource Sensor}"/>
<Ellipse Grid.Column="13"
Fill="{Binding VariableList[21].sValue, Converter={StaticResource StringToBackgroundConverter}}"
Style="{StaticResource Sensor}"/>
<Ellipse Grid.Column="16"
Fill="{Binding VariableList[22].sValue, Converter={StaticResource StringToBackgroundConverter}}"
Style="{StaticResource Sensor}"/>
<Ellipse Grid.Column="19"
Fill="{Binding VariableList[23].sValue, Converter={StaticResource StringToBackgroundConverter}}"
Style="{StaticResource Sensor}"/>
<Ellipse Grid.Column="22"
Fill="{Binding VariableList[41].sValue, Converter={StaticResource StringToBackgroundConverter}}"
Style="{StaticResource Sensor}"/>
<Ellipse Grid.Column="25"
Fill="{Binding VariableList[42].sValue, Converter={StaticResource StringToBackgroundConverter}}"
Style="{StaticResource Sensor}"/>
<Ellipse Grid.Column="27"
Fill="{Binding VariableList[43].sValue, Converter={StaticResource StringToBackgroundConverter}}"
Style="{StaticResource Sensor}"/>
<Ellipse Grid.Column="29"
Fill="{Binding VariableList[44].sValue, Converter={StaticResource StringToBackgroundConverter}}"
Style="{StaticResource Sensor}"/>
<Ellipse Grid.Column="31"
Fill="{Binding VariableList[45].sValue, Converter={StaticResource StringToBackgroundConverter}}"
Style="{StaticResource Sensor}"/>
<Ellipse Grid.Column="34"
Fill="{Binding VariableList[46].sValue, Converter={StaticResource StringToBackgroundConverter}}"
Style="{StaticResource Sensor}"/>
<Ellipse Grid.Column="37"
Fill="{Binding VariableList[47].sValue, Converter={StaticResource StringToBackgroundConverter}}"
Style="{StaticResource Sensor}"/>
</Grid>
<!--Porte-->
<Grid Grid.Column="1"
Grid.Row="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.7*"/>
<ColumnDefinition Width="2.5*"/>
<ColumnDefinition Width="0.3*"/>
<ColumnDefinition Width="2.5*"/>
<ColumnDefinition Width="0.3*"/>
<ColumnDefinition Width="2.5*"/>
<ColumnDefinition Width="0.3*"/>
<ColumnDefinition Width="2.5*"/>
<ColumnDefinition Width="0.3*"/>
<ColumnDefinition Width="2.5*"/>
<ColumnDefinition Width="0.3*"/>
<ColumnDefinition Width="2.5*"/>
<ColumnDefinition Width="0.3*"/>
<ColumnDefinition Width="2.5*"/>
<ColumnDefinition Width="0.3*"/>
<ColumnDefinition Width="2.5*"/>
<ColumnDefinition Width="0.3*"/>
<ColumnDefinition Width="2.5*"/>
<ColumnDefinition Width="0.7*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1.9*"/>
<RowDefinition Height="1.1*"/>
<RowDefinition Height="1.9*"/>
</Grid.RowDefinitions>
<Border Grid.Column="1"
Grid.Row="1"
Visibility="{Binding VariableList[0].sValue, Converter={StaticResource StringToVisibilityConverter}}"
Style="{StaticResource Door}">
<TextBlock Text="5"
FontSize="20"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
<TextBlock Text="{Binding DoorIndexOnMachine[0]}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
</Border>
</Canvas>-->
<Border Grid.Column="3"
Grid.Row="1"
Visibility="{Binding VariableList[1].sValue, Converter={StaticResource StringToVisibilityConverter}}"
Style="{StaticResource Door}">
<TextBlock Text="{Binding DoorIndexOnMachine[1]}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
</Border>
<Border Grid.Column="5"
Grid.Row="1"
Visibility="{Binding VariableList[2].sValue, Converter={StaticResource StringToVisibilityConverter}}"
Style="{StaticResource Door}">
<TextBlock Text="{Binding DoorIndexOnMachine[2]}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
</Border>
<Border Grid.Column="7"
Grid.Row="1"
Visibility="{Binding VariableList[3].sValue, Converter={StaticResource StringToVisibilityConverter}}"
Style="{StaticResource Door}">
<TextBlock Text="{Binding DoorIndexOnMachine[3]}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
</Border>
<Border Grid.Column="9"
Grid.Row="1"
Visibility="{Binding VariableList[4].sValue, Converter={StaticResource StringToVisibilityConverter}}"
Style="{StaticResource Door}">
<TextBlock Text="{Binding DoorIndexOnMachine[4]}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
</Border>
<Border Grid.Column="11"
Grid.Row="1"
Visibility="{Binding VariableList[25].sValue, Converter={StaticResource StringToVisibilityConverter}}"
Style="{StaticResource Door}">
<TextBlock Text="{Binding DoorIndexOnMachine[5]}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
</Border>
<Border Grid.Column="13"
Grid.Row="1"
Visibility="{Binding VariableList[26].sValue, Converter={StaticResource StringToVisibilityConverter}}"
Style="{StaticResource Door}">
<TextBlock Text="{Binding DoorIndexOnMachine[6]}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
</Border>
<Border Grid.Column="15"
Grid.Row="1"
Visibility="{Binding VariableList[27].sValue, Converter={StaticResource StringToVisibilityConverter}}"
Style="{StaticResource Door}">
<TextBlock Text="{Binding DoorIndexOnMachine[7]}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
</Border>
<Border Grid.Column="17"
Grid.Row="1"
Visibility="{Binding VariableList[28].sValue, Converter={StaticResource StringToVisibilityConverter}}"
Style="{StaticResource Door}">
<TextBlock Text="{Binding DoorIndexOnMachine[8]}"
Style="{StaticResource MachDrawVar_TextBlock}"/>
</Border>
</Grid>
</Grid>
<Grid Grid.Row="1">
<!--Bottoni macchina vecchi-->
<!--<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
@@ -151,28 +680,28 @@
<TextBlock Text="Avanza porta in M1S1"/>
<Button Content="0"
Command="{Binding MoveVariable_Command}"
CommandParameter="1,1,1360->1,1,1361"
CommandParameter="1,1,1360/1,980->1,1,1361/1,981"
Width="30"/>
</StackPanel>
<StackPanel>
<TextBlock Text="Avanza porta in M1S2"/>
<Button Content="0"
Command="{Binding MoveVariable_Command}"
CommandParameter="1,1,1361->1,1,1362"
CommandParameter="1,1,1361/1,981->1,1,1362/1,982"
Width="30"/>
</StackPanel>
<StackPanel>
<TextBlock Text="Avanza porta in M1S3"/>
<Button Content="0"
Command="{Binding MoveVariable_Command}"
CommandParameter="1,1,1362->1,1,1363"
CommandParameter="1,1,1362/1,982->1,1,1363/1,983"
Width="30"/>
</StackPanel>
<StackPanel>
<TextBlock Text="Avanza porta in M1S4/M2S0"/>
<Button Content="0"
Command="{Binding MoveVariable_Command}"
CommandParameter="1,1,1363->1,1,1364;2,1,1360"
CommandParameter="1,1,1363/1,983->1,1,1364;2,1,1360/1,984;2,980"
Width="30"/>
</StackPanel>
<StackPanel>
@@ -190,28 +719,28 @@
<TextBlock Text="Avanza porta in M2S1"/>
<Button Content="0"
Command="{Binding MoveVariable_Command}"
CommandParameter="1,1,1364;2,1,1360->2,1,1361"
CommandParameter="1,1,1364;2,1,1360/1,984;2,980->2,1,1361/2,981"
Width="30"/>
</StackPanel>
<StackPanel>
<TextBlock Text="Avanza porta in M2S2"/>
<Button Content="0"
Command="{Binding MoveVariable_Command}"
CommandParameter="2,1,1361->2,1,1362"
CommandParameter="2,1,1361/2,981->2,1,1362/2,982"
Width="30"/>
</StackPanel>
<StackPanel>
<TextBlock Text="Avanza porta in M2S3"/>
<Button Content="0"
Command="{Binding MoveVariable_Command}"
CommandParameter="2,1,1362->2,1,1363"
CommandParameter="2,1,1362/2,982->2,1,1363/2,983"
Width="30"/>
</StackPanel>
<StackPanel>
<TextBlock Text="Avanza porta in M2S4"/>
<Button Content="0"
Command="{Binding MoveVariable_Command}"
CommandParameter="2,1,1363->2,1,1364"
CommandParameter="2,1,1363/2,983->2,1,1364/2,984"
Width="30"/>
</StackPanel>
</StackPanel>
@@ -271,6 +800,134 @@
CommandParameter="2,1,1352,5"
Width="30"/>
</StackPanel>
</Grid>-->
<!--Lista circolare porte-->
<Grid Grid.Row="2"
Visibility="{Binding DoorCircList_Visibility}">
<ItemsControl ItemsSource="{Binding LuaDoorList}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Columns="10"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Column="0"
Grid.Row="0"
Text="Id"/>
<TextBlock Grid.Column="1"
Grid.Row="0"
Text="{Binding nId}"/>
<TextBlock Grid.Column="0"
Grid.Row="1"
Text="Circular Index"/>
<TextBlock Grid.Column="1"
Grid.Row="1"
Text="{Binding nCircIndex}"/>
<TextBlock Grid.Column="0"
Grid.Row="2"
Text="State"/>
<TextBlock Grid.Column="1"
Grid.Row="2"
Text="{Binding nState}"/>
<TextBlock Grid.Column="0"
Grid.Row="3"
Text="DDF Name"/>
<TextBlock Grid.Column="1"
Grid.Row="3"
Text="{Binding sDDFName}"/>
<TextBlock Grid.Column="0"
Grid.Row="4"
Text="CSV Name"/>
<TextBlock Grid.Column="1"
Grid.Row="4"
Text="{Binding sCSVName}"/>
<TextBlock Grid.Column="0"
Grid.Row="5"
Text="DoorCode"/>
<TextBlock Grid.Column="1"
Grid.Row="5"
Text="{Binding sDoorCode}"/>
<TextBlock Grid.Column="0"
Grid.Row="6"
Text="DoorDescription"/>
<TextBlock Grid.Column="1"
Grid.Row="6"
Text="{Binding sDoorDescription}"/>
<TextBlock Grid.Column="0"
Grid.Row="7"
Text="M1 CN Path"/>
<TextBlock Grid.Column="1"
Grid.Row="7"
Text="{Binding sM1CNPath}"/>
<TextBlock Grid.Column="0"
Grid.Row="8"
Text="M2 CN Path"/>
<TextBlock Grid.Column="1"
Grid.Row="8"
Text="{Binding sM2CNPath}"/>
<TextBlock Grid.Column="0"
Grid.Row="9"
Text="Load Time"/>
<TextBlock Grid.Column="1"
Grid.Row="9"
Text="{Binding sLoadTime}"/>
<TextBlock Grid.Column="0"
Grid.Row="10"
Text="Machining 1 Start"/>
<TextBlock Grid.Column="1"
Grid.Row="10"
Text="{Binding sMachining1Start}"/>
<TextBlock Grid.Column="0"
Grid.Row="11"
Text="Machining 1 End"/>
<TextBlock Grid.Column="1"
Grid.Row="11"
Text="{Binding sMachining1End}"/>
<TextBlock Grid.Column="0"
Grid.Row="12"
Text="Machining 2 Start"/>
<TextBlock Grid.Column="1"
Grid.Row="12"
Text="{Binding sMachining2Start}"/>
<TextBlock Grid.Column="0"
Grid.Row="13"
Text="Machining 2 End"/>
<TextBlock Grid.Column="1"
Grid.Row="13"
Text="{Binding sMachining2End}"/>
<TextBlock Grid.Column="0"
Grid.Row="14"
Text="UnloadTime"/>
<TextBlock Grid.Column="1"
Grid.Row="14"
Text="{Binding sUnloadTime}"/>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</Grid>
</Grid>
@@ -1,10 +1,14 @@
Imports System.Collections.ObjectModel
Imports System.ComponentModel.Composition
Imports System.Globalization
Imports System.Reflection
Imports System.Windows.Threading
Imports Newtonsoft.Json.Linq
Imports Supervisor.Plugin.FiveLakes.Variable
Imports Supervisor.Plugin.Interface
Public Class MachinePageVM
Inherits VMBase
Private m_DoorOnMachineList As New ObservableCollection(Of Door)
Public ReadOnly Property DoorOnMachineList As ObservableCollection(Of Door)
@@ -22,9 +26,77 @@ Public Class MachinePageVM
End Get
End Property
Private m_sMachineImagePath As String
Public ReadOnly Property sMachineImagePath As String
Get
Return m_sMachineImagePath
End Get
End Property
Private m_nDDfCalcState As Integer = -1
Public ReadOnly Property nDDfCalcState As Integer
Get
Return m_nDDfCalcState
End Get
End Property
Private Sub SetDDfCalcState(nState As Integer)
m_nDDfCalcState = nState
NotifyPropertyChanged(NameOf(nDDfCalcState))
End Sub
Private m_nNewDoorState As Integer = -1
Public ReadOnly Property nNewDoorState As Integer
Get
Return m_nNewDoorState
End Get
End Property
Private Sub SetNewDoorState(nState As Integer)
m_nNewDoorState = nState
NotifyPropertyChanged(NameOf(nNewDoorState))
End Sub
Private m_DoorIndexOnMachine(8) As Integer
Public ReadOnly Property DoorIndexOnMachine As Integer()
Get
Return m_DoorIndexOnMachine
End Get
End Property
Private m_LuaDoorList As New ObservableCollection(Of LuaDoor)
Public ReadOnly Property LuaDoorList As ObservableCollection(Of LuaDoor)
Get
Return m_LuaDoorList
End Get
End Property
Public ReadOnly Property VariableList_Visibility As Visibility
Get
Return If(GetPluginPrivateProfileInt(S_DEBUG, K_VARIABLELIST, 0) <> 0, Visibility.Visible, Visibility.Collapsed)
End Get
End Property
Public ReadOnly Property VariableOnDraw_Visibility As Visibility
Get
Return If(GetPluginPrivateProfileInt(S_DEBUG, K_VARIABLEONDRAW, 0) <> 0, Visibility.Visible, Visibility.Collapsed)
End Get
End Property
Public ReadOnly Property MachineCommands_Visibility As Visibility
Get
Return If(GetPluginPrivateProfileInt(S_DEBUG, K_MACHINECOMMANDS, 0) <> 0, Visibility.Visible, Visibility.Collapsed)
End Get
End Property
Public ReadOnly Property DoorCircList_Visibility As Visibility
Get
Return If(GetPluginPrivateProfileInt(S_DEBUG, K_DOORCIRCLIST, 0) <> 0, Visibility.Visible, Visibility.Collapsed)
End Get
End Property
' Definizione comandi
Private m_cmdWriteVariable As ICommand
Private m_cmdMoveVariable As ICommand
Private m_cmdManageMachining As ICommand
Sub New()
m_VariableList = New ObservableCollection(Of Variable)({New Variable(Variable.VariableTypes.DOUBLE, "@WP_PR_00", "980", 1),
@@ -79,10 +151,15 @@ Public Class MachinePageVM
m_VarTimer.Interval = New TimeSpan(100)
m_VarTimer.Start()
m_DoorOnMachineList.Add(New Door(35, 1, "Test.ddf", "Produzione2024", 1, 800, 1800, 40, {""}, {""}))
Dim sResourcesDirPath As String = ""
GetPluginPrivateProfileString(S_GENERAL, K_RESOURCESDIR, "", sResourcesDirPath)
m_sMachineImagePath = sResourcesDirPath & "\FiveLakesMachine.png"
End Sub
Friend Sub VarTimer_Tick()
For Each Var In m_VariableList
' leggo variabili da macchina
For nVarIndex As Integer = 0 To m_VariableList.Count - 1
Dim Var As Variable = m_VariableList(nVarIndex)
Select Case Var.Type
Case Variable.VariableTypes.INTEGER
Dim nIndex As Integer = 0
@@ -115,6 +192,77 @@ Public Class MachinePageVM
Map.refSupervisorFunction.PlgOutLog("Error! Reading Variable " & Var.sIndex & " on machine " & Var.nMachine & "failed!")
End If
End Select
If nVarIndex >= 5 AndAlso nVarIndex <= 9 Then
Dim nId As Integer = -1
If LuaGetGlobVar("ListaCircPorte." & Var.nValue & ".Id", nId) Then
m_DoorIndexOnMachine(nVarIndex - 5) = nId
Else
m_DoorIndexOnMachine(nVarIndex - 5) = 0
End If
End If
If nVarIndex >= 30 AndAlso nVarIndex <= 33 Then
Dim nId As Integer = -1
If LuaGetGlobVar("ListaCircPorte." & Var.nValue & ".Id", nId) Then
m_DoorIndexOnMachine(nVarIndex - 25) = nId
Else
m_DoorIndexOnMachine(nVarIndex - 25) = 0
End If
End If
Next
NotifyPropertyChanged(NameOf(DoorIndexOnMachine))
' leggo stato calcolo da lua
Dim nState As Integer = -1
If LuaGetGlobVar("MACHINE1.DDfCalcState", nState) Then
SetDDfCalcState(nState)
End If
If LuaGetGlobVar("MACHINE1.NewDoorState", nState) Then
SetNewDoorState(nState)
End If
m_LuaDoorList.Clear()
For nDoorIndex = 1 To 10
Dim nId As Integer = -1
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".Id", nId)
Dim nCircIndex As Integer = -1
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".IndiceCirc", nCircIndex)
Dim nDoorState As Integer = -1
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".Stato", nDoorState)
Dim sDoorCode As String = ""
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".CodicePorta", sDoorCode)
Dim sDoorDescription As String = ""
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".DescrizionePorta", sDoorDescription)
Dim sDDFName As String = ""
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".NomeDDF", sDDFName)
Dim sCSVName As String = ""
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".NomeCSV", sCSVName)
Dim sM1CNPath As String = ""
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".CN_macchina_1", sM1CNPath)
Dim sM2CNPath As String = ""
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".CN_macchina_2", sM2CNPath)
Dim lLoadTime As Long = 0
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".tempo_carico", lLoadTime)
Dim lMachining1Start As Long = 0
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".tempo_inizio_lav_1", lMachining1Start)
Dim lMachining1End As Long = 0
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".tempo_fine_lav_1", lMachining1End)
Dim lMachining2Start As Long = 0
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".tempo_inizio_lav_2", lMachining2Start)
Dim lMachining2End As Long = 0
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".tempo_fine_lav_2", lMachining2End)
Dim lUnloadTime As Long = 0
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".tempo_scarico", lUnloadTime)
m_LuaDoorList.Add(New LuaDoor(nId, nCircIndex, nDoorState, sDoorCode, sDoorDescription, sDDFName, sCSVName, sM1CNPath, sM2CNPath, lLoadTime, lMachining1Start, lMachining1End, lMachining2Start, lMachining2End, lUnloadTime))
If nId > 0 Then
Dim Door As Door = Map.refDoorListPageVM.DoorList.FirstOrDefault(Function(x) x.nId = nId)
If nDoorState <> Door.nProdState Then
Door.SetProdState(nDoorState)
If lLoadTime > 0 Then Door.SetLoadTime(lLoadTime)
If lMachining1Start > 0 Then Door.SetMachining1Start(lMachining1Start)
If lMachining1End > 0 Then Door.SetMachining1End(lMachining1End)
If lMachining2Start > 0 Then Door.SetMachining2Start(lMachining2Start)
If lMachining2End > 0 Then Door.SetMachining2End(lMachining2End)
If lUnloadTime > 0 Then Door.SetUnloadTime(lUnloadTime)
End If
End If
Next
End Sub
@@ -132,34 +280,37 @@ Public Class MachinePageVM
End Property
Public Sub WriteVariable(sVariable As String)
Dim sVariableArgs As String() = sVariable.Split(","c)
Dim nMachineIndex As Integer = -1
Integer.TryParse(sVariableArgs(0), nMachineIndex)
Dim nVariableType As Integer = -1
Integer.TryParse(sVariableArgs(1), nVariableType)
Select Case nVariableType
Case 1
Dim nVarAddress As Integer = -1
Integer.TryParse(sVariableArgs(2), nVarAddress)
Dim nVarValue As Integer = -1
Integer.TryParse(sVariableArgs(3), nVarValue)
Map.refSupervisorFunction.ComWriteShortVar(nVarAddress, nVarValue, nMachineIndex)
Case 2
Dim nVarAddress As Integer = -1
Integer.TryParse(sVariableArgs(2), nVarAddress)
Dim dVarValue As Double = -1
StringToDouble(sVariableArgs(3), dVarValue)
Map.refSupervisorFunction.ComWriteDoubleVar(nVarAddress, dVarValue, nMachineIndex)
Case 3
Dim sVarAddress As String() = sVariableArgs(2).Split("."c)
Dim nVarAddress As Integer = -1
Integer.TryParse(sVarAddress(0), nVarAddress)
Dim nBit As Integer = -1
Integer.TryParse(sVarAddress(1), nBit)
Dim nVarValue As Integer = -1
Integer.TryParse(sVariableArgs(3), nVarValue)
Map.refSupervisorFunction.ComWriteBitVar(nVarAddress, nBit, nVarValue <> 0, nMachineIndex)
End Select
Dim sVariables As String() = sVariable.Split(";"c)
For nVariableIndex As Integer = 0 To sVariables.Count - 1
Dim sVariableArgs As String() = sVariables(nVariableIndex).Split(","c)
Dim nMachineIndex As Integer = -1
Integer.TryParse(sVariableArgs(0), nMachineIndex)
Dim nVariableType As Integer = -1
Integer.TryParse(sVariableArgs(1), nVariableType)
Select Case nVariableType
Case 1
Dim nVarAddress As Integer = -1
Integer.TryParse(sVariableArgs(2), nVarAddress)
Dim nVarValue As Integer = -1
Integer.TryParse(sVariableArgs(3), nVarValue)
Map.refSupervisorFunction.ComWriteShortVar(nVarAddress, nVarValue, nMachineIndex)
Case 2
Dim nVarAddress As Integer = -1
Integer.TryParse(sVariableArgs(2), nVarAddress)
Dim dVarValue As Double = -1
StringToDouble(sVariableArgs(3), dVarValue)
Map.refSupervisorFunction.ComWriteDoubleVar(nVarAddress, dVarValue, nMachineIndex)
Case 3
Dim sVarAddress As String() = sVariableArgs(2).Split("."c)
Dim nVarAddress As Integer = -1
Integer.TryParse(sVarAddress(0), nVarAddress)
Dim nBit As Integer = -1
Integer.TryParse(sVarAddress(1), nBit)
Dim nVarValue As Integer = -1
Integer.TryParse(sVariableArgs(3), nVarValue)
Map.refSupervisorFunction.ComWriteBitVar(nVarAddress, nBit, nVarValue <> 0, nMachineIndex)
End Select
Next
End Sub
#End Region ' WriteVariable
@@ -177,8 +328,35 @@ Public Class MachinePageVM
Public Sub MoveVariable(sVariableToMove As String)
Dim sVariableToMoveArgs As String() = sVariableToMove.Split({"->"}, StringSplitOptions.None)
Dim sFromAndPresenceVariables As String() = sVariableToMoveArgs(0).Split("/"c)
' verifico presenza da variabile di partenza
Dim sVerifyFromVariables As String() = sFromAndPresenceVariables(0).Split(";"c)
Dim sVerifyFromVariableArgs As String() = sVerifyFromVariables(0).Split(","c)
Dim nVerifyFromMachineIndex As Integer = -1
Integer.TryParse(sVerifyFromVariableArgs(0), nVerifyFromMachineIndex)
Dim nVerifyFromVarAddress As Integer = -1
Integer.TryParse(sVerifyFromVariableArgs(2), nVerifyFromVarAddress)
Dim dVerifyFromVarValue As Double = -1
Map.refSupervisorFunction.ComReadShortVar(nVerifyFromVarAddress, dVerifyFromVarValue, nVerifyFromMachineIndex)
If dVerifyFromVarValue < 1 Then Return
' verifco se variabile dopo macchina, che la macchina abbia lavorato
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
End If
' verifico che stazione di destinazione non sia gia' occupata
Dim sToAndPresenceVariables As String() = sVariableToMoveArgs(1).Split("/"c)
Dim sVerifyToVariables As String() = sToAndPresenceVariables(1).Split(";"c)
Dim sVerifyToVariableArgs As String() = sVerifyToVariables(0).Split(","c)
Dim nVerifyToMachineIndex As Integer = -1
Integer.TryParse(sVerifyToVariableArgs(0), nVerifyToMachineIndex)
Dim nVerifyToVarAddress As Integer = -1
Integer.TryParse(sVerifyToVariableArgs(2), nVerifyToVarAddress)
Dim dVerifyToVarValue As Double = -1
Map.refSupervisorFunction.ComReadDoubleVar(nVerifyToVarAddress, dVerifyToVarValue, nVerifyToMachineIndex)
If dVerifyToVarValue > 0 Then Return
' leggo variabili di partenza
Dim sFromVariables As String() = sVariableToMoveArgs(0).Split(";"c)
Dim sFromVariables As String() = sFromAndPresenceVariables(0).Split(";"c)
Dim sFromVariableArgs As String() = sFromVariables(0).Split(","c)
Dim nFromMachineIndex As Integer = -1
Integer.TryParse(sFromVariableArgs(0), nFromMachineIndex)
@@ -204,8 +382,8 @@ Public Class MachinePageVM
Integer.TryParse(sVarAddress(1), nBit)
Map.refSupervisorFunction.ComReadBitVar(nVarAddress, nBit, bVarValue, nFromMachineIndex)
End Select
' scrivo valore in variabili di arivo
Dim sToVariables As String() = sVariableToMoveArgs(1).Split(";"c)
' scrivo valore in variabili di arrivo
Dim sToVariables As String() = sToAndPresenceVariables(0).Split(";"c)
For nToVariableIndex As Integer = 0 To sToVariables.Count - 1
Dim sToVariableArgs As String() = sToVariables(nToVariableIndex).Split(","c)
Dim nToMachineIndex As Integer = -1
@@ -270,10 +448,112 @@ Public Class MachinePageVM
Map.refSupervisorFunction.ComWriteBitVar(nVarAddress, nBit, False, nFromMachineIndex)
End Select
Next
' resetto presenza da variabili di partenza
Dim sFromPresenceVariables As String() = sFromAndPresenceVariables(1).Split(";"c)
For nFromPresenceVariableIndex As Integer = 0 To sFromPresenceVariables.Count - 1
Dim sFromPresenceVariableArgs As String() = sFromPresenceVariables(nFromPresenceVariableIndex).Split(","c)
Dim nFromPresenceMachineIndex As Integer = -1
Integer.TryParse(sFromPresenceVariableArgs(0), nFromPresenceMachineIndex)
Dim nFromPresenceVariableType As Integer = -1
Integer.TryParse(sFromPresenceVariableArgs(1), nFromPresenceVariableType)
Select Case nFromPresenceVariableType
Case 1
Dim nVarAddress As Integer = -1
Integer.TryParse(sFromPresenceVariableArgs(2), nVarAddress)
Map.refSupervisorFunction.ComWriteShortVar(nVarAddress, 0, nFromPresenceMachineIndex)
Case 2
Dim nVarAddress As Integer = -1
Integer.TryParse(sFromPresenceVariableArgs(2), nVarAddress)
Map.refSupervisorFunction.ComWriteDoubleVar(nVarAddress, 0, nFromPresenceMachineIndex)
Case 3
Dim sVarAddress As String() = sFromPresenceVariableArgs(2).Split("."c)
Dim nVarAddress As Integer = -1
Integer.TryParse(sVarAddress(0), nVarAddress)
Dim nBit As Integer = -1
Integer.TryParse(sVarAddress(1), nBit)
Map.refSupervisorFunction.ComWriteBitVar(nVarAddress, nBit, False, nFromPresenceMachineIndex)
End Select
Next
' imposto presenza in variabili di arrivo
Dim sToPresenceVariables As String() = sToAndPresenceVariables(1).Split(";"c)
For nToPresenceVariableIndex As Integer = 0 To sToPresenceVariables.Count - 1
Dim sToPresenceVariableArgs As String() = sToPresenceVariables(nToPresenceVariableIndex).Split(","c)
Dim nToPresenceMachineIndex As Integer = -1
Integer.TryParse(sToPresenceVariableArgs(0), nToPresenceMachineIndex)
Dim nVarAddress As Integer = -1
Integer.TryParse(sToPresenceVariableArgs(2), nVarAddress)
Map.refSupervisorFunction.ComWriteDoubleVar(nVarAddress, 1, nToPresenceMachineIndex)
Next
End Sub
#End Region ' MoveVariable
#Region "ManageMachining"
Public ReadOnly Property ManageMachining_Command As ICommand
Get
If m_cmdManageMachining Is Nothing Then
m_cmdManageMachining = New Command(AddressOf ManageMachining)
End If
Return m_cmdManageMachining
End Get
End Property
Public Sub ManageMachining(sArg As String)
Dim sArgs As String() = sArg.Split(","c)
Dim nMachineIndex As Integer = -1
Dim nStartStop As Integer = -1
Integer.TryParse(sArgs(0), nMachineIndex)
Integer.TryParse(sArgs(1), nStartStop)
Dim nVarAddress As Integer
If nMachineIndex = 1 Then
nVarAddress = 1352
ElseIf nMachineIndex = 2 Then
nVarAddress = 1352
Else Return
End If
Dim nState As Integer
Dim StateVariable As Variable = m_VariableList.FirstOrDefault(Function(x) x.nMachine = nMachineIndex AndAlso x.sName = "@STATE")
Dim Sent1 As Variable = m_VariableList.FirstOrDefault(Function(x) x.nMachine = nMachineIndex AndAlso x.sName = "@SENT_1")
Dim Sent2 As Variable = m_VariableList.FirstOrDefault(Function(x) x.nMachine = nMachineIndex AndAlso x.sName = "@SENT_2")
Dim DoorPresence As Variable = m_VariableList.FirstOrDefault(Function(x) x.nMachine = nMachineIndex AndAlso x.sName = "@WP_PR_02")
If StateVariable.nValue < 1 OrElse StateVariable.nValue > 5 Then Return
Select Case StateVariable.nValue
Case 0
Return
Case 1
If nStartStop = 1 AndAlso DoorPresence.dValue = 1 AndAlso Sent1.nValue = 1 Then
nState = 2
Map.refSupervisorFunction.ComWriteShortVar(Sent1.sIndex, 0, nMachineIndex)
Else Return
End If
Case 2
If nStartStop = 2 Then
nState = 3
Else Return
End If
Case 3
If nStartStop = 1 AndAlso DoorPresence.dValue = 1 AndAlso Sent2.nValue = 1 Then
nState = 4
Map.refSupervisorFunction.ComWriteShortVar(Sent2.sIndex, 0, nMachineIndex)
Else Return
End If
Case 4
If nStartStop = 2 Then
nState = 5
Else Return
End If
Case 5
If nStartStop = 1 Then
nState = 2
Else Return
End If
End Select
Map.refSupervisorFunction.ComWriteShortVar(nVarAddress, nState, nMachineIndex)
End Sub
#End Region ' ManageMachining
#End Region ' COMMANDS
End Class
@@ -316,7 +596,17 @@ Public Class Variable
End Property
Private m_nValue As Integer
Friend ReadOnly Property nValue As Integer
Get
Return m_nValue
End Get
End Property
Private m_dValue As Double
Friend ReadOnly Property dValue As Integer
Get
Return m_dValue
End Get
End Property
Private m_bValue As Boolean
Public Property sValue As String
Get
@@ -371,3 +661,269 @@ Public Class Variable
End Sub
End Class
Public Class LuaDoor
Inherits VMBase
Private m_nId As Integer = -1
Public ReadOnly Property nId As Integer
Get
Return m_nId
End Get
End Property
Private m_nCircIndex As Integer = -1
Public ReadOnly Property nCircIndex As Integer
Get
Return m_nCircIndex
End Get
End Property
Private m_nState As Integer = 0
Public ReadOnly Property nState As Integer
Get
Return m_nState
End Get
End Property
Private m_sDoorCode As String = ""
Public ReadOnly Property sDoorCode As String
Get
Return m_sDoorCode
End Get
End Property
Private m_sDoorDescription As String = ""
Public ReadOnly Property sDoorDescription As String
Get
Return m_sDoorDescription
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_sCSVName As String = ""
Public ReadOnly Property sCSVName As String
Get
Return m_sCSVName
End Get
End Property
Private m_sM1CNPath As String = ""
Public ReadOnly Property sM1CNPath As String
Get
Return m_sM1CNPath
End Get
End Property
Private m_sM2CNPath As String = ""
Public ReadOnly Property sM2CNPath As String
Get
Return m_sM2CNPath
End Get
End Property
Private m_dtLoadTime As DateTime
Public ReadOnly Property sLoadTime As String
Get
Return m_dtLoadTime.ToString("yy/MM/dd HH:mm:ss")
End Get
End Property
Private m_dtMachining1Start As DateTime
Public ReadOnly Property sMachining1Start As String
Get
Return m_dtMachining1Start.ToString("yy/MM/dd HH:mm:ss")
End Get
End Property
Private m_dtMachining1End As DateTime
Public ReadOnly Property sMachining1End As String
Get
Return m_dtMachining1End.ToString("yy/MM/dd HH:mm:ss")
End Get
End Property
Private m_dtMachining2Start As DateTime
Public ReadOnly Property sMachining2Start As String
Get
Return m_dtMachining2Start.ToString("yy/MM/dd HH:mm:ss")
End Get
End Property
Private m_dtMachining2End As DateTime
Public ReadOnly Property sMachining2End As String
Get
Return m_dtMachining2End.ToString("yy/MM/dd HH:mm:ss")
End Get
End Property
Private m_dtUnloadTime As DateTime
Public ReadOnly Property sUnloadTime As String
Get
Return m_dtUnloadTime.ToString("yy/MM/dd HH:mm:ss")
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,
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_sDoorCode = sDoorCode
m_sDoorDescription = sDoorDescription
m_sDDFName = sDDFName
m_sCSVName = sCSVName
m_sM1CNPath = sM1CNPath
m_sM2CNPath = sM2CNPath
m_dtLoadTime = New DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(lLoadTime).ToLocalTime()
m_dtMachining1Start = New DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(lMachining1Start).ToLocalTime()
m_dtMachining1End = New DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(lMachining1End).ToLocalTime()
m_dtMachining2Start = New DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(lMachining2Start).ToLocalTime()
m_dtMachining2End = New DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(lMachining2End).ToLocalTime()
m_dtUnloadTime = New DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(lUnloadTime).ToLocalTime()
End Sub
End Class
Public Class StringToVisibilityConverter
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 String OrElse String.IsNullOrWhiteSpace(value) Then Return Visibility.Collapsed
Dim sValue As String = value
Dim sLowerValue As String = sValue.ToLower()
If sLowerValue = "true" Then Return Visibility.Visible
If sLowerValue = "false" Then Return Visibility.Collapsed
Dim nValue As Integer
If Not Integer.TryParse(sValue, nValue) Then Return Visibility.Collapsed
Return If(nValue <> 0, 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 StringToMachineStateConverter
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 String OrElse String.IsNullOrWhiteSpace(value) Then Return Visibility.Collapsed
Dim sValue As String = value
Dim nValue As Integer
If Not Integer.TryParse(sValue, nValue) Then Return ""
Select Case nValue
Case -1
Return "Not Initialized"
Case 0
Return "Reset"
Case 1
Return "Initialized"
Case 2
Return "Start machining 1000"
Case 3
Return "End machining 1000"
Case 4
Return "Start machining 2000"
Case 5
Return "End machining 2000"
Case Else
Return "Unknown State"
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 StringToDDFCalcStateConverter
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 Integer Then Return value
Dim sValue As String = value
Dim nValue As Integer = value
Select Case nValue
Case 0
Return "Null"
Case 1
Return "Running"
Case 2
Return "Result"
Case Else
Return value
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 StringToNewDoorStateConverter
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 Integer Then Return value
Dim nValue As Integer = value
Select Case nValue
Case 0
Return "Null"
Case 1
Return "Present"
Case 2
Return "Assigned"
Case Else
Return value
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 StringToBooleanConverter
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 String OrElse String.IsNullOrWhiteSpace(value) Then Return False
Dim sValue As String = value
Dim nValue As Integer
If Not Integer.TryParse(sValue, nValue) Then Return False
Return nValue <> 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
Public Class StringToBackgroundConverter
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 String OrElse String.IsNullOrWhiteSpace(value) Then Return False
Dim sValue As String = value
Dim nValue As Integer
If Not Integer.TryParse(sValue, nValue) Then Return Brushes.LightGray
Return If(nValue <> 0, Brushes.Green, Brushes.LightGray)
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
@@ -1,17 +1,32 @@
<Grid x:Class="MainMenuV"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
DataContext="{StaticResource MainMenuVM}"
WindowChrome.IsHitTestVisibleInChrome="True">
<Grid.Resources>
<sys:Int32 x:Key="Door_List">0</sys:Int32>
<sys:Int32 x:Key="Machine_State">1</sys:Int32>
<sys:Int32 x:Key="Statistics">2</sys:Int32>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Button Content="Door List"
Command="{Binding DoorList_Command}"/>
<Button Grid.Column="1"
Content="Machine Status"
Command="{Binding MachineStatus_Command}"/>
<Button Grid.Column="2"
Content="Statistics"
Command="{Binding Statistics_Command}"/>
<RadioButton Content="Door List"
Command="{Binding Page_Command}"
CommandParameter="{StaticResource Door_List}"
IsChecked="True"
Style="{StaticResource {x:Type ToggleButton}}"/>
<RadioButton Grid.Column="1"
Content="Machine Status"
Command="{Binding Page_Command}"
CommandParameter="{StaticResource Machine_State}"
Style="{StaticResource {x:Type ToggleButton}}"/>
<RadioButton Grid.Column="2"
Content="Statistics"
Command="{Binding Page_Command}"
CommandParameter="{StaticResource Statistics}"
Style="{StaticResource {x:Type ToggleButton}}"/>
</Grid>
@@ -1,28 +1,27 @@
Public Class MainMenuVM
Inherits VMBase
' Definizione comandi
Private m_cmdDoorList As ICommand
Private m_cmdMachineStatus As ICommand
Private m_cmdStatistics As ICommand
Private m_cmdPage As ICommand
#Region "COMMANDS"
#Region "DoorList"
#Region "Page"
Public ReadOnly Property DoorList_Command As ICommand
Public ReadOnly Property Page_Command As ICommand
Get
If m_cmdDoorList Is Nothing Then
m_cmdDoorList = New Command(AddressOf DoorList)
If m_cmdPage Is Nothing Then
m_cmdPage = New Command(AddressOf Page)
End If
Return m_cmdDoorList
Return m_cmdPage
End Get
End Property
Public Sub DoorList()
Public Sub Page(nPage As Integer)
Map.refFiveLakesUIVM.SetSelPage(nPage)
End Sub
#End Region ' DoorList
#End Region ' Page
#End Region ' COMMANDS
@@ -0,0 +1,12 @@
<UserControl x:Class="StatisticsPageV"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Supervisor.Plugin.FiveLakes"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
</Grid>
</UserControl>
@@ -0,0 +1,3 @@
Public Class StatisticsPageV
End Class
@@ -0,0 +1,3 @@
Public Class StatisticsPageVM
End Class
@@ -120,6 +120,10 @@
</Compile>
<Compile Include="MainMenu\MainMenuVM.vb" />
<Compile Include="ProcessManager\ProcessManagerVM.vb" />
<Compile Include="StatisticsPage\StatisticsPageV.xaml.vb">
<DependentUpon>StatisticsPageV.xaml</DependentUpon>
</Compile>
<Compile Include="StatisticsPage\StatisticsPageVM.vb" />
<Compile Include="Utility\Dictionary.xaml.vb">
<DependentUpon>Dictionary.xaml</DependentUpon>
</Compile>
@@ -176,12 +180,15 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="StatisticsPage\StatisticsPageV.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Utility\Dictionary.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
<PropertyGroup>
<PreBuildEvent>powershell.exe -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -File $(ProjectDir)\pre-build.ps1 -ProjectDir $(ProjectDir) -ProjectPath $(ProjectPath)</PreBuildEvent>
@@ -10,8 +10,10 @@
it in xaml file(ProjectView.xaml).
-->
<local:FiveLakesUIVM x:Key="FiveLakesUIVM"/>
<local:MainMenuVM x:Key="MainMenuVM"/>
<local:DoorListPageVM x:Key="DoorListVM"/>
<local:MachinePageVM x:Key="MachinePageVM"/>
<local:StatisticsPageVM x:Key="StatisticsPageVM"/>
<!--Colori predefiniti-->
<SolidColorBrush x:Key="EgaltechBlue1" Color="#FF4D84C4" />
@@ -24,6 +26,12 @@
<SolidColorBrush x:Key="EgaltechUltralightGray" Color="#FFF2F2F2" />
<SolidColorBrush x:Key="EgaltechGreen" Color="#FF00FF00" />
<SolidColorBrush x:Key="Roller" Color="#FF585858" />
<SolidColorBrush x:Key="TableFrame" Color="LightGray" />
<SolidColorBrush x:Key="Structure" Color="#61b0ff" />
<SolidColorBrush x:Key="Bridge" Color="LightBlue" />
<SolidColorBrush x:Key="Shuttle" Color="DarkGray" />
<!--#92908d-->
<Color x:Key="Icarus_Gray_Color" R="146" G="144" B="141" A="255"/>
<SolidColorBrush x:Key="Icarus_Gray" Color="{StaticResource Icarus_Gray_Color}" />
@@ -83,8 +83,64 @@ Public Class JsonDoor
End Get
End Property
#Region "Statistics"
Private m_nProdState As DoorProdStates = DoorProdStates.NOT_INIT
<JsonProperty>
<JsonConverter(GetType(StringEnumConverter))>
Public ReadOnly Property nProdState As DoorProdStates
Get
Return m_nProdState
End Get
End Property
Private m_dtLoadTime As DateTime = DateTime.MinValue
Public ReadOnly Property dtLoadTime As DateTime
Get
Return m_dtLoadTime
End Get
End Property
Private m_dtMachining1Start As DateTime = DateTime.MinValue
Public ReadOnly Property dtMachining1Start As DateTime
Get
Return m_dtMachining1Start
End Get
End Property
Private m_dtMachining1End As DateTime = DateTime.MinValue
Public ReadOnly Property dtMachining1End As DateTime
Get
Return m_dtMachining1End
End Get
End Property
Private m_dtMachining2Start As DateTime = DateTime.MinValue
Public ReadOnly Property dtMachining2Start As DateTime
Get
Return m_dtMachining2Start
End Get
End Property
Private m_dtMachining2End As DateTime = DateTime.MinValue
Public ReadOnly Property dtMachining2End As DateTime
Get
Return m_dtMachining2End
End Get
End Property
Private m_dtUnloadTime As DateTime = DateTime.MinValue
Public ReadOnly Property dtUnloadTime As DateTime
Get
Return m_dtUnloadTime
End Get
End Property
#End Region ' Statistics
<JsonConstructor>
Sub New(nListIndex As Integer, nId As Integer, nCSVLine As Integer, sDDFName As String, sCSVName As String, nQuantity As Integer, dWidth As Double, dHeight As Double, dThickness As Double, nState As DoorStates, CustomerParameters As List(Of CustomerParameter))
Sub New(nListIndex As Integer, nId As Integer, nCSVLine As Integer, sDDFName As String, sCSVName As String, nQuantity As Integer, dWidth As Double, dHeight As Double, dThickness As Double, nState As DoorStates, CustomerParameters As List(Of CustomerParameter),
nProdState As DoorProdStates, dtLoadTime As DateTime, dtMachining1Start As DateTime, dtMachining1End As DateTime, dtMachining2Start As DateTime, dtMachining2End As DateTime, dtUnloadTime As DateTime)
m_nListIndex = nListIndex
m_nId = nId
m_nCSVLine = nCSVLine
@@ -96,6 +152,13 @@ Public Class JsonDoor
m_dThickness = dThickness
m_nState = nState
m_CustomerParameters = CustomerParameters
m_nProdState = nProdState
m_dtLoadTime = dtLoadTime
m_dtMachining1Start = dtMachining1Start
m_dtMachining1End = dtMachining1End
m_dtMachining2Start = dtMachining2Start
m_dtMachining2End = dtMachining2End
m_dtUnloadTime = dtUnloadTime
End Sub
Sub New(nListIndex As Integer, Door As Door)
@@ -110,6 +173,13 @@ Public Class JsonDoor
m_dThickness = Door.dThickness
m_nState = Door.nState
m_CustomerParameters = Door.CustomerParameters
m_nProdState = Door.nProdState
m_dtLoadTime = Door.dtLoadTime
m_dtMachining1Start = Door.dtMachining1Start
m_dtMachining1End = Door.dtMachining1End
m_dtMachining2Start = Door.dtMachining2Start
m_dtMachining2End = Door.dtMachining2End
m_dtUnloadTime = Door.dtUnloadTime
End Sub
End Class