- letta modalita' simulazione macchina anche in plugin
- disabilitato sort su colonne lista porte - corretta riattivazione bottoni dopo calcolo - corretta acquisizione risultato da calcolo porta - corrette funzioni lua con parametro inutile - cambiato valori di avanzamento variabili porta in WP per scarico uguale a 2 - cambiata sorgente indice porta su disegnino - aggiunta lista porte a finestra di restart - aggiunta a finestra di restart lettura json del lua - aggiunta classe IdNameStruct
This commit is contained in:
@@ -31,4 +31,7 @@ Module ConstIni
|
||||
Public Const K_MACHINECOMMANDS As String = "MachineCommands"
|
||||
Public Const K_DOORCIRCLIST As String = "DoorCircList"
|
||||
|
||||
Public Const S_NC As String = "NC"
|
||||
Public Const K_NC_SIMULATE As String = "NcSimulate"
|
||||
|
||||
End Module
|
||||
|
||||
@@ -42,7 +42,8 @@
|
||||
<DataGrid Grid.Row="1"
|
||||
ItemsSource="{Binding DoorList}"
|
||||
SelectedItem="{Binding SelDoor}"
|
||||
AutoGenerateColumns="False">
|
||||
AutoGenerateColumns="False"
|
||||
CanUserSortColumns="False">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header=""
|
||||
Binding="{Binding nId}"
|
||||
|
||||
@@ -156,7 +156,7 @@ Public Class DoorListPageVM
|
||||
' ciclo su coda risultati
|
||||
Dim ArgumentsResult As ProcessArgsResult = m_ExecProcessManager.ArgumentsResultDequeue
|
||||
While Not IsNothing(ArgumentsResult)
|
||||
' aggiorno risultatao sulla porta
|
||||
' aggiorno risultato sulla porta
|
||||
Dim CurrRequestDoor As Door = m_DoorList.FirstOrDefault(Function(x) x.nId = ArgumentsResult.ProcessArgs.nId)
|
||||
If Not IsNothing(CurrRequestDoor) Then
|
||||
CurrRequestDoor.SetState(If(ArgumentsResult.nResult = 0, Door.DoorStates.VERIFIED, Door.DoorStates.VERIFICATION_FAILED))
|
||||
@@ -164,6 +164,9 @@ Public Class DoorListPageVM
|
||||
WriteBackup()
|
||||
ArgumentsResult = m_ExecProcessManager.ArgumentsResultDequeue
|
||||
End While
|
||||
If Not bExecButton_IsEnabled AndAlso m_ExecProcessManager.ExecutionThreadStatus = ExecProcessManager.ExecutionThreadStatuses.STOPPED Then
|
||||
SetExecButtonIsEnabled(True)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Friend Function GetNextDoor() As Door
|
||||
@@ -316,7 +319,6 @@ Public Class DoorListPageVM
|
||||
|
||||
Public Sub ExecProcessManager_AllArgsProcessed()
|
||||
m_ExecProcessManager.StopExecutionThread()
|
||||
SetExecButtonIsEnabled(True)
|
||||
End Sub
|
||||
|
||||
Public Sub ExecProcessManager_PostProcess(ProcessArgsResult As ProcessArgsResult)
|
||||
@@ -547,7 +549,7 @@ Public Class DoorListPageVM
|
||||
Dim sDDFDirPath As String = ""
|
||||
GetPluginPrivateProfileString(S_GENERAL, "DDFDir", "", sDDFDirPath)
|
||||
For Each Door In m_DoorList
|
||||
If Door.nState = Door.DoorStates.LOADED_FROM_CSV Then
|
||||
If Door.nState = Door.DoorStates.LOADED_FROM_CSV Or Door.nState = Door.DoorStates.VERIFICATION_FAILED Then
|
||||
Dim sDDFFilePath As String = sDDFDirPath & "\" & Door.sDDFName
|
||||
m_ExecProcessManager.ArgumentsEnqueue(New ProcessArgs(Door.nId, sDDFFilePath))
|
||||
End If
|
||||
|
||||
@@ -13,15 +13,13 @@ Public Module Lua_General
|
||||
|
||||
Private Function Lua_PlgGetNumberFromIni(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
' 4 parametri: sSec, sKey, dDef, sIniFile
|
||||
' 4 parametri: sSec, sKey, dDef
|
||||
Dim sSec As String = ""
|
||||
Dim sKey As String = ""
|
||||
Dim dDef As Integer = 0
|
||||
Dim sIniFile As String = ""
|
||||
LuaCheckParam(state, 1, sSec)
|
||||
LuaCheckParam(state, 2, sKey)
|
||||
LuaCheckParam(state, 3, dDef)
|
||||
LuaCheckParam(state, 4, sIniFile)
|
||||
LuaClearStack(state)
|
||||
Dim dResult As Double = GetPluginPrivateProfileDouble(sSec, sKey, dDef)
|
||||
' restituisco il risultato
|
||||
@@ -31,15 +29,13 @@ Public Module Lua_General
|
||||
|
||||
Private Function Lua_PlgGetStringFromIni(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
' 4 parametri: sSec, sKey, sDef, sIniFile
|
||||
' 4 parametri: sSec, sKey, sDef
|
||||
Dim sSec As String = ""
|
||||
Dim sKey As String = ""
|
||||
Dim sDef As String = 0
|
||||
Dim sIniFile As String = ""
|
||||
LuaCheckParam(state, 1, sSec)
|
||||
LuaCheckParam(state, 2, sKey)
|
||||
LuaCheckParam(state, 3, sDef)
|
||||
LuaCheckParam(state, 4, sIniFile)
|
||||
LuaClearStack(state)
|
||||
Dim sResult As String = ""
|
||||
GetPluginPrivateProfileString(sSec, sKey, sDef, sResult)
|
||||
@@ -50,15 +46,13 @@ Public Module Lua_General
|
||||
|
||||
Private Function Lua_PlgWriteStringToIni(ByVal p As IntPtr) As Integer
|
||||
Dim state = Lua.FromIntPtr(p)
|
||||
' 4 parametri: sSec, sKey, sVal, sIniFile
|
||||
' 4 parametri: sSec, sKey, sVal
|
||||
Dim sSec As String = ""
|
||||
Dim sKey As String = ""
|
||||
Dim sVal As Integer = 0
|
||||
Dim sIniFile As String = ""
|
||||
LuaCheckParam(state, 1, sSec)
|
||||
LuaCheckParam(state, 2, sKey)
|
||||
LuaCheckParam(state, 3, sVal)
|
||||
LuaCheckParam(state, 4, sIniFile)
|
||||
LuaClearStack(state)
|
||||
Dim bResult As Boolean = WritePluginPrivateProfileString(sSec, sKey, sVal)
|
||||
' restituisco il risultato
|
||||
|
||||
@@ -489,7 +489,7 @@
|
||||
<Button Grid.Column="7"
|
||||
Content="Go To
M2S1"
|
||||
Command="{Binding MoveVariable_Command}"
|
||||
CommandParameter="1,1,1364;2,1,1360/1,2,984;2,2,980->2,1,1361/2,2,981"
|
||||
CommandParameter="2,1,1360;1,1,1364/1,2,984;2,2,980->2,1,1361/2,2,981"
|
||||
Style="{StaticResource Advancement_Button}"/>
|
||||
<Button Grid.Column="8"
|
||||
Content="Go To
M2S2"
|
||||
@@ -794,42 +794,42 @@
|
||||
Grid.Row="1"
|
||||
Visibility="{Binding VariableList[0].sValue, Converter={StaticResource StringToVisibilityConverter}}"
|
||||
Style="{StaticResource Door}">
|
||||
<TextBlock Text="{Binding DoorIndexOnMachine[0]}"
|
||||
<TextBlock Text="{Binding DoorOnMachineArray[0].nId}"
|
||||
Style="{StaticResource MachDrawVar_TextBlock}"/>
|
||||
</Border>
|
||||
<Border Grid.Column="3"
|
||||
Grid.Row="1"
|
||||
Visibility="{Binding VariableList[1].sValue, Converter={StaticResource StringToVisibilityConverter}}"
|
||||
Style="{StaticResource Door}">
|
||||
<TextBlock Text="{Binding DoorIndexOnMachine[1]}"
|
||||
<TextBlock Text="{Binding DoorOnMachineArray[1].nId}"
|
||||
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]}"
|
||||
<TextBlock Text="{Binding DoorOnMachineArray[2].nId}"
|
||||
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]}"
|
||||
<TextBlock Text="{Binding DoorOnMachineArray[3].nId}"
|
||||
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]}"
|
||||
<TextBlock Text="{Binding DoorOnMachineArray[4].nId}"
|
||||
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]}"
|
||||
<TextBlock Text="{Binding DoorOnMachineArray[5].nId}"
|
||||
Style="{StaticResource MachDrawVar_TextBlock}"/>
|
||||
|
||||
</Border>
|
||||
@@ -837,21 +837,21 @@
|
||||
Grid.Row="1"
|
||||
Visibility="{Binding VariableList[26].sValue, Converter={StaticResource StringToVisibilityConverter}}"
|
||||
Style="{StaticResource Door}">
|
||||
<TextBlock Text="{Binding DoorIndexOnMachine[6]}"
|
||||
<TextBlock Text="{Binding DoorOnMachineArray[6].nId}"
|
||||
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]}"
|
||||
<TextBlock Text="{Binding DoorOnMachineArray[7].nId}"
|
||||
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]}"
|
||||
<TextBlock Text="{Binding DoorOnMachineArray[8].nId}"
|
||||
Style="{StaticResource MachDrawVar_TextBlock}"/>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
@@ -55,13 +55,6 @@ Public Class MachinePageVM
|
||||
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_DoorOnMachineArray(8) As LuaDoor
|
||||
Public ReadOnly Property DoorOnMachineArray As LuaDoor()
|
||||
Get
|
||||
@@ -199,24 +192,39 @@ 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))
|
||||
' se in simulazione
|
||||
If Map.refSupervisorFunction.PlgGetPrivateProfileInt(S_NC, K_NC_SIMULATE, 0) Then
|
||||
' aggiorno stato porta in macchina da 1 a 2 se in stazione di lavorazione
|
||||
For nMachineIndex = 1 To 2
|
||||
Dim nMachineId As Integer = nMachineIndex
|
||||
Dim Machine1Var As Variable = m_VariableList.FirstOrDefault(Function(x) x.sName = "@WP_PR_02" AndAlso x.nMachine = nMachineId)
|
||||
If Not IsNothing(Machine1Var) AndAlso Machine1Var.dValue = 1 Then
|
||||
Dim nIndex As Integer = -1
|
||||
Integer.TryParse(Machine1Var.sIndex, nIndex)
|
||||
Map.refSupervisorFunction.ComWriteDoubleVar(nIndex, 2, Machine1Var.nMachine)
|
||||
End If
|
||||
Next
|
||||
' se presente un sent
|
||||
Dim Sent1Var As Variable = m_VariableList.FirstOrDefault(Function(x) x.sName = "@SENT_1" AndAlso x.nMachine = 2)
|
||||
Dim Sent2Var As Variable = m_VariableList.FirstOrDefault(Function(x) x.sName = "@SENT_2" AndAlso x.nMachine = 2)
|
||||
If Sent1Var.nValue = 1 OrElse Sent2Var.nValue = 1 Then
|
||||
' aggiorno stato porta su rulliera intermedia da 2 a 1
|
||||
For nMachineIndex = 1 To 2
|
||||
Dim nMachineId As Integer = nMachineIndex
|
||||
Dim sVariableName As String = "@WP_PR_04"
|
||||
If nMachineIndex = 2 Then
|
||||
sVariableName = "@WP_PR_00"
|
||||
End If
|
||||
Dim Machine1Var As Variable = m_VariableList.FirstOrDefault(Function(x) x.sName = sVariableName AndAlso x.nMachine = nMachineId)
|
||||
If Not IsNothing(Machine1Var) AndAlso Machine1Var.dValue = 2 Then
|
||||
Dim nIndex As Integer = -1
|
||||
Integer.TryParse(Machine1Var.sIndex, nIndex)
|
||||
Map.refSupervisorFunction.ComWriteDoubleVar(nIndex, 1, Machine1Var.nMachine)
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
' leggo stato calcolo da lua
|
||||
Dim nState As Integer = -1
|
||||
If LuaGetGlobVar("MACHINE1.DDfCalcState", nState) Then
|
||||
@@ -228,35 +236,35 @@ Public Class MachinePageVM
|
||||
m_LuaDoorList.Clear()
|
||||
For nDoorIndex = 1 To 10
|
||||
Dim nId As Integer = -1
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".Id", nId)
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".nId", nId)
|
||||
Dim nCircIndex As Integer = -1
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".IndiceCirc", nCircIndex)
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".nCircIndex", nCircIndex)
|
||||
Dim nDoorState As Integer = -1
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".Stato", nDoorState)
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".nState", nDoorState)
|
||||
Dim sDoorCode As String = ""
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".CodicePorta", sDoorCode)
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".sDoorCode", sDoorCode)
|
||||
Dim sDoorDescription As String = ""
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".DescrizionePorta", sDoorDescription)
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".sDoorDescription", sDoorDescription)
|
||||
Dim sDDFName As String = ""
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".NomeDDF", sDDFName)
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".sDDFName", sDDFName)
|
||||
Dim sCSVName As String = ""
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".NomeCSV", sCSVName)
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".sCSVName", sCSVName)
|
||||
Dim sM1CNPath As String = ""
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".CN_macchina_1", sM1CNPath)
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".sM1CNPath", sM1CNPath)
|
||||
Dim sM2CNPath As String = ""
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".CN_macchina_2", sM2CNPath)
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".sM2CNPath", sM2CNPath)
|
||||
Dim lLoadTime As Long = 0
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".tempo_carico", lLoadTime)
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".nLoadTime", lLoadTime)
|
||||
Dim lMachining1Start As Long = 0
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".tempo_inizio_lav_1", lMachining1Start)
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".nMachining1Start", lMachining1Start)
|
||||
Dim lMachining1End As Long = 0
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".tempo_fine_lav_1", lMachining1End)
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".nMachining1End", lMachining1End)
|
||||
Dim lMachining2Start As Long = 0
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".tempo_inizio_lav_2", lMachining2Start)
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".nMachining2Start", lMachining2Start)
|
||||
Dim lMachining2End As Long = 0
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".tempo_fine_lav_2", lMachining2End)
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".nMachining2End", lMachining2End)
|
||||
Dim lUnloadTime As Long = 0
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".tempo_scarico", lUnloadTime)
|
||||
LuaGetGlobVar("ListaCircPorte." & nDoorIndex & ".nUnloadTime", lUnloadTime)
|
||||
m_LuaDoorList.Add(New LuaDoor(nId, nCircIndex, nDoorState, sDoorCode, sDoorDescription, sDDFName, sCSVName, sM1CNPath, sM2CNPath, lLoadTime, lMachining1Start, lMachining1End, lMachining2Start, lMachining2End, lUnloadTime))
|
||||
If nId > 0 Then
|
||||
' aggiorno dati in lista porte
|
||||
@@ -276,6 +284,7 @@ Public Class MachinePageVM
|
||||
For nVarIndex As Integer = 0 To m_VariableList.Count - 1
|
||||
Dim Var As Variable = m_VariableList(nVarIndex)
|
||||
If nVarIndex >= 5 AndAlso nVarIndex <= 9 Then
|
||||
Dim nId As Integer = -1
|
||||
If Var.nValue > 0 Then
|
||||
m_DoorOnMachineArray(nVarIndex - 5) = m_LuaDoorList(Var.nValue - 1)
|
||||
Else
|
||||
@@ -284,14 +293,15 @@ Public Class MachinePageVM
|
||||
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
|
||||
If Var.nValue > 0 Then
|
||||
m_DoorOnMachineArray(nVarIndex - 25) = m_LuaDoorList(Var.nValue - 1)
|
||||
Else
|
||||
m_DoorIndexOnMachine(nVarIndex - 25) = 0
|
||||
m_DoorOnMachineArray(nVarIndex - 25) = Nothing
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
NotifyPropertyChanged(NameOf(DoorOnMachineArray))
|
||||
End Sub
|
||||
|
||||
#Region "COMMANDS"
|
||||
@@ -367,7 +377,15 @@ Public Class MachinePageVM
|
||||
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
|
||||
' verifco se variabile di carico, che la macchina abbia iniziato a lavorare
|
||||
If nVerifyFromVarAddress = 1360 Then
|
||||
Dim MachineStateVar As Variable = VariableList.FirstOrDefault(Function(x) x.nMachine = nVerifyFromMachineIndex AndAlso x.sName = "@STATE")
|
||||
Dim Sent1Var As Variable = VariableList.FirstOrDefault(Function(x) x.nMachine = nVerifyFromMachineIndex AndAlso x.sName = "@SENT_1")
|
||||
Dim Sent2Var As Variable = VariableList.FirstOrDefault(Function(x) x.nMachine = nVerifyFromMachineIndex AndAlso x.sName = "@SENT_2")
|
||||
If (MachineStateVar.nValue <> 2 AndAlso MachineStateVar.nValue <> 4) OrElse
|
||||
Sent1Var.nValue <> 0 OrElse Sent2Var.nValue <> 0 Then Return
|
||||
End If
|
||||
' verifco se variabile tavolo di lavoro, che la macchina abbia finito di lavorare
|
||||
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
|
||||
@@ -488,10 +506,12 @@ Public Class MachinePageVM
|
||||
Case 1
|
||||
Dim nVarAddress As Integer = -1
|
||||
Integer.TryParse(sFromPresenceVariableArgs(2), nVarAddress)
|
||||
Map.refSupervisorFunction.ComReadShortVar(nVarAddress, nVarValue, nFromPresenceMachineIndex)
|
||||
Map.refSupervisorFunction.ComWriteShortVar(nVarAddress, 0, nFromPresenceMachineIndex)
|
||||
Case 2
|
||||
Dim nVarAddress As Integer = -1
|
||||
Integer.TryParse(sFromPresenceVariableArgs(2), nVarAddress)
|
||||
Map.refSupervisorFunction.ComReadDoubleVar(nVarAddress, dVarValue, nFromPresenceMachineIndex)
|
||||
Map.refSupervisorFunction.ComWriteDoubleVar(nVarAddress, 0, nFromPresenceMachineIndex)
|
||||
Case 3
|
||||
Dim sVarAddress As String() = sFromPresenceVariableArgs(2).Split("."c)
|
||||
@@ -499,6 +519,7 @@ Public Class MachinePageVM
|
||||
Integer.TryParse(sVarAddress(0), nVarAddress)
|
||||
Dim nBit As Integer = -1
|
||||
Integer.TryParse(sVarAddress(1), nBit)
|
||||
Map.refSupervisorFunction.ComReadBitVar(nVarAddress, nBit, bVarValue, nFromPresenceMachineIndex)
|
||||
Map.refSupervisorFunction.ComWriteBitVar(nVarAddress, nBit, False, nFromPresenceMachineIndex)
|
||||
End Select
|
||||
Next
|
||||
@@ -510,7 +531,7 @@ Public Class MachinePageVM
|
||||
Integer.TryParse(sToPresenceVariableArgs(0), nToPresenceMachineIndex)
|
||||
Dim nVarAddress As Integer = -1
|
||||
Integer.TryParse(sToPresenceVariableArgs(2), nVarAddress)
|
||||
Map.refSupervisorFunction.ComWriteDoubleVar(nVarAddress, 1, nToPresenceMachineIndex)
|
||||
Map.refSupervisorFunction.ComWriteDoubleVar(nVarAddress, dVarValue, nToPresenceMachineIndex)
|
||||
Next
|
||||
End Sub
|
||||
|
||||
@@ -544,36 +565,38 @@ Public Class MachinePageVM
|
||||
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")
|
||||
Dim StartDoorPresence As Variable = m_VariableList.FirstOrDefault(Function(x) x.nMachine = nMachineIndex AndAlso x.sName = "@WP_PR_00")
|
||||
Dim EndDoorPresence 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
|
||||
If nStartStop = 1 AndAlso StartDoorPresence.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
|
||||
If nStartStop = 2 AndAlso EndDoorPresence.dValue = 2 Then
|
||||
nState = 3
|
||||
Else Return
|
||||
End If
|
||||
Case 3
|
||||
If nStartStop = 1 AndAlso DoorPresence.dValue = 1 AndAlso Sent2.nValue = 1 Then
|
||||
If nStartStop = 1 AndAlso StartDoorPresence.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
|
||||
If nStartStop = 2 AndAlso EndDoorPresence.dValue = 2 Then
|
||||
nState = 5
|
||||
Else Return
|
||||
End If
|
||||
Case 5
|
||||
If nStartStop = 1 Then
|
||||
If nStartStop = 1 AndAlso StartDoorPresence.dValue = 1 AndAlso Sent1.nValue = 1 Then
|
||||
nState = 2
|
||||
Map.refSupervisorFunction.ComWriteShortVar(Sent1.sIndex, 0, nMachineIndex)
|
||||
Else Return
|
||||
End If
|
||||
End Select
|
||||
|
||||
@@ -6,8 +6,75 @@
|
||||
xmlns:local="clr-namespace:Supervisor.Plugin.FiveLakes"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Window.Resources>
|
||||
<local:StateToVisibilityConverter x:Key="StateToVisibilityConverter"/>
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
<Button Content="Ok"
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="1*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<ItemsControl ItemsSource="{Binding RestartDoorList}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<UniformGrid Rows="1"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Visibility="{Binding nState, Converter={StaticResource StateToVisibilityConverter}}">
|
||||
<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"/>
|
||||
</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}"/>
|
||||
<ComboBox Grid.Column="1"
|
||||
Grid.Row="2"
|
||||
ItemsSource="{Binding DoorStateList}"
|
||||
SelectedItem="{Binding SelStateList}"/>
|
||||
<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 Text="Id"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
<Button Grid.Row="1"
|
||||
Content="Ok"
|
||||
Command="{Binding Ok_Command}"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
Imports Newtonsoft.Json
|
||||
Imports System.Collections.ObjectModel
|
||||
Imports System.Globalization
|
||||
Imports System.IO
|
||||
|
||||
Public Class RestartWndVM
|
||||
@@ -9,23 +10,40 @@ Public Class RestartWndVM
|
||||
' Definizione comandi
|
||||
Private m_cmdOk As ICommand
|
||||
|
||||
Private m_RestartDoorList As ObservableCollection(Of JsonLuaDoor)
|
||||
Public ReadOnly Property RestartDoorList As ObservableCollection(Of JsonLuaDoor)
|
||||
Get
|
||||
Return m_RestartDoorList
|
||||
End Get
|
||||
End Property
|
||||
|
||||
#Region "CONSTRUCTOR"
|
||||
|
||||
Sub New()
|
||||
Dim sBackupFilePath As String = ""
|
||||
GetPluginPrivateProfileString("General", "BackupDir", "", sBackupFilePath)
|
||||
sBackupFilePath &= "/LuaBackup.json"
|
||||
sBackupFilePath &= "\LuaBackup.json"
|
||||
|
||||
|
||||
|
||||
If File.Exists(sBackupFilePath) Then
|
||||
Dim sReadedFile As String = File.ReadAllText(sBackupFilePath)
|
||||
|
||||
Dim JsonDoorList As List(Of LuaDoor) = JsonConvert.DeserializeObject(Of List(Of LuaDoor))(sReadedFile)
|
||||
'JsonDoorList = JsonDoorList.OrderBy(Of Integer)(Function(x) x.nListIndex).ToList()
|
||||
Dim JsonLuaDoorList As List(Of JsonLuaDoor) = JsonConvert.DeserializeObject(Of List(Of JsonLuaDoor))(sReadedFile)
|
||||
JsonLuaDoorList = JsonLuaDoorList.OrderBy(Of Integer)(Function(x) x.nCircIndex).ToList()
|
||||
|
||||
m_RestartDoorList = New ObservableCollection(Of JsonLuaDoor)((From JsonLuaDoor In Map.refDoorListPageVM.DoorList
|
||||
Select New JsonLuaDoor(JsonLuaDoor)).ToList())
|
||||
For JsonLuaDoorIndex = 0 To JsonLuaDoorList.Count - 1
|
||||
Dim JsonLuaDoor As JsonLuaDoor = JsonLuaDoorList(JsonLuaDoorIndex)
|
||||
Dim RestartDoor As JsonLuaDoor = m_RestartDoorList.FirstOrDefault(Function(x) x.nId = JsonLuaDoor.nId)
|
||||
If Not IsNothing(RestartDoor) Then
|
||||
RestartDoor.Update(JsonLuaDoor)
|
||||
End If
|
||||
|
||||
|
||||
Next
|
||||
|
||||
'm_DoorList = New ObservableCollection(Of Door)((From JsonDoor In JsonDoorList
|
||||
' Select New Door(JsonDoor)).ToList())
|
||||
End If
|
||||
|
||||
|
||||
@@ -58,3 +76,188 @@ Public Class RestartWndVM
|
||||
#End Region ' COMMANDS
|
||||
|
||||
End Class
|
||||
|
||||
Public Class StateToVisibilityConverter
|
||||
Implements IValueConverter
|
||||
|
||||
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.Convert
|
||||
If IsNothing(value) OrElse Not TypeOf value Is Integer Then Return Visibility.Collapsed
|
||||
Return If(value > 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 RestartDoor
|
||||
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_DoorStateList As New List(Of IdNameStruct)({New IdNameStruct(0, "Not On Machine"),
|
||||
New IdNameStruct(1, "Imported"),
|
||||
New IdNameStruct(2, "On Load"),
|
||||
New IdNameStruct(3, "On Machine 1"),
|
||||
New IdNameStruct(4, "On Medium Station"),
|
||||
New IdNameStruct(6, "On Machine 2"),
|
||||
New IdNameStruct(7, "On Unload"),
|
||||
New IdNameStruct(8, "Produced"),
|
||||
New IdNameStruct(100, "Scrap")})
|
||||
Public ReadOnly Property DoorStateList As List(Of IdNameStruct)
|
||||
Get
|
||||
Return m_DoorStateList
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private m_SelDoorState As IdNameStruct
|
||||
Public Property SelDoorState As IdNameStruct
|
||||
Get
|
||||
Return m_SelDoorState
|
||||
End Get
|
||||
Set(value As IdNameStruct)
|
||||
m_SelDoorState = value
|
||||
End Set
|
||||
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(Id As Integer, IndiceCirc As Integer, Stato As Integer, CodicePorta As String, DescrizionePorta As String, NomeDDF As String, NomeCSV As String,
|
||||
CN_macchina_1 As String, CN_macchina_2 As String, tempo_carico As Long, tempo_inizio_lav_1 As Long, tempo_fine_lav_1 As Long, tempo_inizio_lav_2 As Long,
|
||||
tempo_fine_lav_2 As Long, tempo_scarico As Long)
|
||||
m_nId = Id
|
||||
m_nCircIndex = IndiceCirc
|
||||
m_nState = Stato
|
||||
m_sDoorCode = CodicePorta
|
||||
m_sDoorDescription = DescrizionePorta
|
||||
m_sDDFName = NomeDDF
|
||||
m_sCSVName = NomeCSV
|
||||
m_sM1CNPath = CN_macchina_1
|
||||
m_sM2CNPath = CN_macchina_2
|
||||
m_dtLoadTime = New DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(tempo_carico).ToLocalTime()
|
||||
m_dtMachining1Start = New DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(tempo_inizio_lav_1).ToLocalTime()
|
||||
m_dtMachining1End = New DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(tempo_fine_lav_1).ToLocalTime()
|
||||
m_dtMachining2Start = New DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(tempo_inizio_lav_2).ToLocalTime()
|
||||
m_dtMachining2End = New DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(tempo_fine_lav_2).ToLocalTime()
|
||||
m_dtUnloadTime = New DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(tempo_scarico).ToLocalTime()
|
||||
End Sub
|
||||
|
||||
Sub New(Door As Door)
|
||||
m_nId = Door.nId
|
||||
m_nCircIndex = 0
|
||||
m_nState = 0
|
||||
m_sDDFName = Door.sDDFName
|
||||
m_sCSVName = Door.sCSVName
|
||||
m_sM1CNPath = ""
|
||||
m_sM2CNPath = ""
|
||||
m_dtLoadTime = DateTime.MinValue
|
||||
m_dtMachining1Start = DateTime.MinValue
|
||||
m_dtMachining1End = DateTime.MinValue
|
||||
m_dtMachining2Start = DateTime.MinValue
|
||||
m_dtMachining2End = DateTime.MinValue
|
||||
m_dtUnloadTime = DateTime.MinValue
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
@@ -147,6 +147,7 @@
|
||||
<Compile Include="Utility\Command.vb" />
|
||||
<Compile Include="Utility\ExecProcessManager.vb" />
|
||||
<Compile Include="Utility\GenInterface.vb" />
|
||||
<Compile Include="Utility\IdNameStruct.vb" />
|
||||
<Compile Include="Utility\IniFile.vb" />
|
||||
<Compile Include="Utility\JsonUtility.vb" />
|
||||
<Compile Include="Utility\Map.vb" />
|
||||
|
||||
@@ -554,9 +554,13 @@ Public Class ExecProcessManager
|
||||
If Results.Count >= 2 Then
|
||||
Dim nIndex As Integer = -1
|
||||
Dim nResult As Integer = -1
|
||||
Dim dResult As Integer = -1
|
||||
If Integer.TryParse(Results(1), nIndex) AndAlso nIndex >= 0 Then
|
||||
If Integer.TryParse(Results(2), nResult) AndAlso nResult >= 0 Then
|
||||
m_ThreadDataList(nIndex).SetProcResult(nResult)
|
||||
ElseIf StringToDouble(Results(2), dResult) AndAlso dResult >= 0 Then
|
||||
nResult = Math.Floor(dResult)
|
||||
m_ThreadDataList(nIndex).SetProcResult(nResult)
|
||||
End If
|
||||
m_ThreadDataList(nIndex).SetProcessStatus(ThreadData.ProcessStatuses.ANSWERRECEIVED)
|
||||
End If
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
Imports System.Collections.ObjectModel
|
||||
|
||||
Public Structure IdNameStruct
|
||||
|
||||
Private m_Id As Integer
|
||||
Public Property Id As Integer
|
||||
Get
|
||||
Return m_Id
|
||||
End Get
|
||||
Set(value As Integer)
|
||||
m_Id = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Private m_Name As String
|
||||
Public Property Name As String
|
||||
Get
|
||||
Return m_Name
|
||||
End Get
|
||||
Set(value As String)
|
||||
m_Name = value
|
||||
End Set
|
||||
End Property
|
||||
|
||||
Sub New(Id As Integer, Name As String)
|
||||
m_Id = Id
|
||||
m_Name = Name
|
||||
End Sub
|
||||
|
||||
Public Overrides Function ToString() As String
|
||||
Return Name
|
||||
End Function
|
||||
|
||||
Public Shared Function IndFromId(Id As Integer, List As ObservableCollection(Of IdNameStruct)) As Integer
|
||||
For i = 0 To List.Count - 1
|
||||
If List(i).Id = Id Then Return i
|
||||
Next
|
||||
Return 0
|
||||
End Function
|
||||
Public Shared Function IndFromId(Id As Integer, List As List(Of IdNameStruct)) As Integer
|
||||
For i = 0 To List.Count - 1
|
||||
If List(i).Id = Id Then Return i
|
||||
Next
|
||||
Return 0
|
||||
End Function
|
||||
|
||||
Public Shared Function IdFromInd(Ind As Integer, List As ObservableCollection(Of IdNameStruct)) As Integer
|
||||
Return List(Ind).Id
|
||||
End Function
|
||||
Public Shared Function IdFromInd(Ind As Integer, List As List(Of IdNameStruct)) As Integer
|
||||
Return List(Ind).Id
|
||||
End Function
|
||||
|
||||
Public Shared Function IndFromId(Id As Integer, List As ObservableCollection(Of Object)) As Integer
|
||||
For i = 0 To List.Count - 1
|
||||
If TypeOf (List(i)) Is IdNameStruct AndAlso DirectCast(List(i), IdNameStruct).Id = Id Then
|
||||
Return i
|
||||
End If
|
||||
Next
|
||||
Return 0
|
||||
End Function
|
||||
Public Shared Function IndFromId(Id As Integer, List As List(Of Object)) As Integer
|
||||
For i = 0 To List.Count - 1
|
||||
If TypeOf (List(i)) Is IdNameStruct AndAlso DirectCast(List(i), IdNameStruct).Id = Id Then
|
||||
Return i
|
||||
End If
|
||||
Next
|
||||
Return 0
|
||||
End Function
|
||||
|
||||
Public Shared Function IdFromInd(Ind As Integer, List As ObservableCollection(Of Object)) As Integer
|
||||
If TypeOf (List(Ind)) Is IdNameStruct Then
|
||||
Return DirectCast(List(Ind), IdNameStruct).Id
|
||||
End If
|
||||
Return 0
|
||||
End Function
|
||||
Public Shared Function IdFromInd(Ind As Integer, List As List(Of Object)) As Integer
|
||||
If TypeOf (List(Ind)) Is IdNameStruct Then
|
||||
Return DirectCast(List(Ind), IdNameStruct).Id
|
||||
End If
|
||||
Return 0
|
||||
End Function
|
||||
|
||||
Public Shared Function IdFromName(Name As String, List As ObservableCollection(Of Object)) As Integer
|
||||
For i = 0 To List.Count - 1
|
||||
If DirectCast(List(i), IdNameStruct).Name = Name Then Return DirectCast(List(i), IdNameStruct).Id
|
||||
Next
|
||||
Return 0
|
||||
End Function
|
||||
Public Shared Function IdFromName(Name As String, List As List(Of Object)) As Integer
|
||||
For i = 0 To List.Count - 1
|
||||
If DirectCast(List(i), IdNameStruct).Name = Name Then Return DirectCast(List(i), IdNameStruct).Id
|
||||
Next
|
||||
Return 0
|
||||
End Function
|
||||
|
||||
End Structure
|
||||
@@ -1,4 +1,5 @@
|
||||
Imports Newtonsoft.Json
|
||||
Imports System.Globalization
|
||||
Imports Newtonsoft.Json
|
||||
Imports Newtonsoft.Json.Converters
|
||||
Imports Supervisor.Plugin.FiveLakes.Door
|
||||
|
||||
@@ -183,3 +184,188 @@ Public Class JsonDoor
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
Public Class JsonLuaDoor
|
||||
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_DoorStateList As New List(Of IdNameStruct)({New IdNameStruct(0, "Not On Machine"),
|
||||
New IdNameStruct(1, "Imported"),
|
||||
New IdNameStruct(2, "On Load"),
|
||||
New IdNameStruct(3, "On Machine 1"),
|
||||
New IdNameStruct(4, "On Medium Station"),
|
||||
New IdNameStruct(6, "On Machine 2"),
|
||||
New IdNameStruct(7, "On Unload"),
|
||||
New IdNameStruct(8, "Produced"),
|
||||
New IdNameStruct(100, "Scrap")})
|
||||
Public ReadOnly Property DoorStateList As List(Of IdNameStruct)
|
||||
Get
|
||||
Return m_DoorStateList
|
||||
End Get
|
||||
End Property
|
||||
|
||||
Private m_SelDoorState As IdNameStruct
|
||||
Public Property SelDoorState As IdNameStruct
|
||||
Get
|
||||
Return m_SelDoorState
|
||||
End Get
|
||||
Set(value As IdNameStruct)
|
||||
m_SelDoorState = value
|
||||
End Set
|
||||
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
|
||||
|
||||
<JsonConstructor>
|
||||
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, nLoadTime As Long, nMachining1Start As Long, nMachining1End As Long, nMachining2Start As Long,
|
||||
nMachining2End As Long, nUnloadTime 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(nLoadTime).ToLocalTime()
|
||||
m_dtMachining1Start = New DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(nMachining1Start).ToLocalTime()
|
||||
m_dtMachining1End = New DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(nMachining1End).ToLocalTime()
|
||||
m_dtMachining2Start = New DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(nMachining2Start).ToLocalTime()
|
||||
m_dtMachining2End = New DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(nMachining2End).ToLocalTime()
|
||||
m_dtUnloadTime = New DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(nUnloadTime).ToLocalTime()
|
||||
End Sub
|
||||
|
||||
Sub New(Door As Door)
|
||||
m_nId = Door.nId
|
||||
m_nCircIndex = 0
|
||||
m_nState = 0
|
||||
m_sDDFName = Door.sDDFName
|
||||
m_sCSVName = Door.sCSVName
|
||||
m_sM1CNPath = ""
|
||||
m_sM2CNPath = ""
|
||||
m_dtLoadTime = DateTime.MinValue
|
||||
m_dtMachining1Start = DateTime.MinValue
|
||||
m_dtMachining1End = DateTime.MinValue
|
||||
m_dtMachining2Start = DateTime.MinValue
|
||||
m_dtMachining2End = DateTime.MinValue
|
||||
m_dtUnloadTime = DateTime.MinValue
|
||||
End Sub
|
||||
|
||||
Friend Sub Update(JsonLuaDoor As JsonLuaDoor)
|
||||
m_nCircIndex = JsonLuaDoor.m_nCircIndex
|
||||
m_nState = JsonLuaDoor.m_nState
|
||||
m_sM1CNPath = JsonLuaDoor.m_sM1CNPath
|
||||
m_sM2CNPath = JsonLuaDoor.m_sM2CNPath
|
||||
m_dtLoadTime = JsonLuaDoor.m_dtLoadTime
|
||||
m_dtMachining1Start = JsonLuaDoor.m_dtMachining1Start
|
||||
m_dtMachining1End = JsonLuaDoor.m_dtMachining1End
|
||||
m_dtMachining2Start = JsonLuaDoor.m_dtMachining2Start
|
||||
m_dtMachining2End = JsonLuaDoor.m_dtMachining2End
|
||||
m_dtUnloadTime = JsonLuaDoor.m_dtUnloadTime
|
||||
End Sub
|
||||
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user