diff --git a/EgtBEAMWALL.Core/Constants/ConstIni.vb b/EgtBEAMWALL.Core/Constants/ConstIni.vb index 68bf00c3..1e7480ff 100644 --- a/EgtBEAMWALL.Core/Constants/ConstIni.vb +++ b/EgtBEAMWALL.Core/Constants/ConstIni.vb @@ -40,6 +40,7 @@ Public Module ConstIni Public Const K_DBMASTERKEY As String = "DbMasterKey" Public Const K_UPDATEBTL As String = "UpdateBtl" Public Const K_DATADIR As String = "DataDir" + Public Const K_ENABLEEDIT As String = "EnableEdit" 'Public Const S_LANGUAGES As String = "Languages" 'Public Const K_LANGUAGE As String = "Language" diff --git a/EgtBEAMWALL.Supervisor/Comms/NUMAxiumPcToolkitComm.vb b/EgtBEAMWALL.Supervisor/Comms/NUMAxiumPcToolkitComm.vb index 74e8f53b..bc5389f2 100644 --- a/EgtBEAMWALL.Supervisor/Comms/NUMAxiumPcToolkitComm.vb +++ b/EgtBEAMWALL.Supervisor/Comms/NUMAxiumPcToolkitComm.vb @@ -45,7 +45,7 @@ Public Class NUMAxiumPcToolkitComm E30000 = 30 ' aggiunto da noi, non presente nella documentazione Num e gestito a parte rispetto agli altri End Enum - Const R1 = &HA401, R2 = &HA402 + Const R1 = &HA401, R2 = &HA402, RL = &HA442 Const VL = &HA042 Public Structure My_data_struct @@ -120,6 +120,10 @@ Public Class NUMAxiumPcToolkitComm Private Shared Function ReadLadderVar(ByVal Port As Int16, ByVal qui As UInt16, ByVal First As UInt16, ByVal Quantity As UInt16, ByRef pData As My_data_struct, ByVal Mode As UInt16) As Int16 End Function + + Private Shared Function WriteLadderVar(ByVal Port As Int16, ByVal qui As UInt16, ByVal First As UInt16, ByVal Quantity As UInt16, ByRef pData As Integer) As Int16 + End Function + Private Shared Function ReadObjectVarious4(ByVal Port As Int16, ByVal qui As UInt16, ByVal First As UInt16, ByVal Quantity As UInt16, ByRef pData As My_data_struct, ByVal Mode As UInt16) As Int16 End Function @@ -346,6 +350,11 @@ Public Class NUMAxiumPcToolkitComm End Sub Friend Sub Start() + ' Annullo variabile E30099 per trasferimento programmi + Dim SendPermissionVariable As Variable = Map.refMachCommandMessagePanelVM.MainVariablesList.FirstOrDefault(Function(x) x.sName = SENDPERMISSION) + If Not IsNothing(SendPermissionVariable) Then + SendPermissionVariable.sValue = 0 + End If Dim nRet As Int16 = -1 nRet = StartNC(nPortCommands) If nRet <> 0 Then @@ -457,19 +466,29 @@ Public Class NUMAxiumPcToolkitComm Try Dim dValue As Double = 0 StringToDouble(value, dValue) - Dim nType As eVarious4 - Dim nValue As Integer = 0 - Dim sAddressNumber As Integer = Address.Substring(1) - Dim nAddressNumber As Integer = 0 - If Not Integer.TryParse(sAddressNumber, nAddressNumber) Then Return - If nAddressNumber >= 30000 AndAlso nAddressNumber < 40000 Then - nType = eVarious4.E30000 - nAddressNumber -= 30000 - End If - Dim Group As UInt16 = 0 - If Not Integer.TryParse(value, nValue) Then Return - EgtOutLog("WritePLCVariables - nType: " & nType & " nFirst: " & nAddressNumber & " Data: " & nValue) - Dim rc As Short = DNC20_WriteE5E6(nPortVariables, Group, 3, nAddressNumber, nValue, SYN) + Select Case Address + Case "E30099" ' in realta' per scrivere si usa la %RD0C.L + Dim nRes = WriteLadderVar(nPortVariables, RL, &HD0C, 1, dValue) + EgtOutLog("Scrittura E30099 - result " & nRes) + Case Else ' E30000 + Dim nType As eVarious4 + Dim nValue As Integer = 0 + Dim sAddressNumber As Integer = Address.Substring(1) + Dim nAddressNumber As Integer = 0 + If Not Integer.TryParse(sAddressNumber, nAddressNumber) Then Return + If nAddressNumber >= 30000 AndAlso nAddressNumber < 40000 Then + nType = eVarious4.E30000 + nAddressNumber -= 30000 + End If + Dim Group As UInt16 = 0 + Dim ParType As UInt16 = 3 + Dim ParPos As UInt16 = nAddressNumber + If Not Integer.TryParse(value, nValue) Then Return + EgtOutLog("WritePLCVariables - nType: " & nType & " nFirst: " & nAddressNumber & " Data: " & nValue) + EgtOutLog("WritePLCVariables - nPortVariables: " & nPortVariables & " Group: " & Group & " ParType: " & ParType & " ParPos: " & ParPos & " nValue: " & nValue) + Dim rc As Short = DNC20_WriteE5E6(nPortVariables, Group, ParType, ParPos, nValue, SYN) + EgtOutLog("WritePLCVariables - return value: " & rc) + End Select 'If rc <> 0 Then EgtOutLog(" objDVariables.WriteVariables2() Error : " & rc) @@ -516,32 +535,37 @@ Public Class NUMAxiumPcToolkitComm ElseIf nAddressNumber >= 80000 Then nType = eVarious4.E80000 nAddressNumber -= 80000 - ElseIf nAddressNumber >= 30000 Then - nType = eVarious4.E30000 - nAddressNumber -= 30000 + 'ElseIf nAddressNumber >= 30000 Then + ' nType = eVarious4.E30000 + ' nAddressNumber -= 30000 + ' EgtOutLog("E30000 var trovata") End If - If nType = eVarious4.E30000 Then - Dim Group As UInt16 = 0 - Dim nVal As Int32 - Dim ObjectList As New tDNC20_ObjectList With {.ElemNum = 3, - .First = nAddressNumber, - .Quantity = 1} - nret = DNC20_ReadExxxxx(nPortVariables, Group, 1, ObjectList, nVal, SYN) - If nret = 0 Then - Var.SetValue(nVal) - End If - Else - nret = ReadObjectVarious4(nPortVariables, nType, nAddressNumber, 1, MyData, SYN) - If nret = 0 Then - 'Var.SetValue(MyData.data(0)) - 'Dim NewBytes(3) As Byte - 'For nBIndex = 3 To 0 Step -1 - ' NewBytes(3 - nBIndex) = MyData.data(nBIndex) - 'Next - Dim nVal As Integer = BitConverter.ToInt32(MyData.data, 0) - Var.SetValue(nVal) - End If + 'If nType = eVarious4.E30000 Then + ' Dim Group As UInt16 = 0 + ' Dim nVal As Int32 + ' Dim ObjectList As New tDNC20_ObjectList With {.ElemNum = 3, + ' .First = nAddressNumber, + ' .Quantity = 1} + ' EgtOutLog("E30000 var trovata, valori: " & nPortVariables & " " & Group & "" & ObjectList.First & " " & nVal) + + ' nret = DNC20_ReadExxxxx(nPortVariables, Group, 1, ObjectList, nVal, SYN) + ' EgtOutLog("E30000 var risultato: " & nret) + ' If nret = 0 Then + ' Var.SetValue(nVal) + ' EgtOutLog("E30000 var assegnata: " & nVal) + ' End If + 'Else + nret = ReadObjectVarious4(nPortVariables, nType, nAddressNumber, 1, MyData, SYN) + If nret = 0 Then + 'Var.SetValue(MyData.data(0)) + 'Dim NewBytes(3) As Byte + 'For nBIndex = 3 To 0 Step -1 + ' NewBytes(3 - nBIndex) = MyData.data(nBIndex) + 'Next + Dim nVal As Integer = BitConverter.ToInt32(MyData.data, 0) + Var.SetValue(nVal) End If + 'End If 'EgtOutLog("Variabile: " & Var.sAddress & " Tipo: " & nType & " NAddres: " & nAddressNumber & " Valore: " & nVal) ElseIf Var.nType = CommVar.Types.PLC Then Dim nRet As Short = -1 @@ -573,9 +597,34 @@ Public Class NUMAxiumPcToolkitComm Case "%V814.L" nRet = ReadLadderVar(nPortVariables, VL, &H814, 4, MyData, SYN) nRes = BitConverter.ToInt32(MyData.data, 0) + Case Else + Dim nType As eVarious4 + Dim sAddressNumber As Integer = Var.sAddress.Substring(1) + Dim nAddressNumber As Integer = 0 + If Not Integer.TryParse(sAddressNumber, nAddressNumber) Then Return + If nAddressNumber >= 30000 Then + nType = eVarious4.E30000 + nAddressNumber -= 30000 + 'EgtOutLog("E30000 var trovata") + End If + If nType = eVarious4.E30000 Then + Dim Group As UInt16 = 0 + Dim ObjectList As New tDNC20_ObjectList With {.ElemNum = 3, + .First = nAddressNumber, + .Quantity = 1} + EgtOutLog("E30000 var trovata, valori: " & nPortVariables & " " & Group & "" & ObjectList.First & " " & nRes) + + nRet = DNC20_ReadExxxxx(nPortVariables, Group, 1, ObjectList, nRes, SYN) + EgtOutLog("E30000 var risultato: " & nRet) + If nRet = 0 Then + Var.SetValue(nRes) + EgtOutLog("E30000 var assegnata: " & nRes) + End If + End If End Select If nRet = 0 Then - EgtOutLog("Variabile: " & Var.sAddress & "DVal: " & nRes & " Valore: " & MyData.data(0) & "," & MyData.data(1) & "," & MyData.data(2) & "," & MyData.data(3)) + 'EgtOutLog("Variabile: " & Var.sAddress & "DVal: " & nRes & " Valore: " & MyData.data(0) & "," & MyData.data(1) & "," & MyData.data(2) & "," & MyData.data(3)) + EgtOutLog("Variabile: " & Var.sAddress & "DVal: " & nRes) Var.SetValue(nRes) End If End If @@ -592,17 +641,24 @@ Public Class NUMAxiumPcToolkitComm Dim SendPermissionVariable As Variable = Map.refMachCommandMessagePanelVM.MainVariablesList.FirstOrDefault(Function(x) x.sName = SENDPERMISSION) Dim dTemp As Double = 0 Dim nSendPermission As Integer = 0 + EgtOutLog("Inizio invio programma") While nSendPermission <> 2 + Dim bFirstWriteOne = True + EgtOutLog("Inizio ciclo verifica diverso da 2") ' leggo valore If Not IsNothing(SendPermissionVariable.sValue) Then StringToDouble(SendPermissionVariable.sValue, dTemp) Integer.TryParse(dTemp, nSendPermission) + EgtOutLog("Lettura variabile E30099: " & nSendPermission) Else + EgtOutLog("nSendPermission = -1") nSendPermission = -1 End If ' se uguale a zero ci scrivo uno - If nSendPermission = 0 Then + If nSendPermission = 0 And bFirstWriteOne Then + bFirstWriteOne = False SendPermissionVariable.sValue = 1 + EgtOutLog("Scrittura variabile E30099 = 1") End If Threading.Thread.Sleep(1000) End While @@ -650,6 +706,7 @@ Public Class NUMAxiumPcToolkitComm End If End If nRes = DownLoadFileAsyn(nPortFileTransfer, nFileType, sFilePath, DNC_MODE_ABORT, nIndex) + SendPermissionVariable.sValue = 0 m_BytesTransferedCounter = 0 m_bIsTransferActive = False Return diff --git a/EgtBEAMWALL.ViewerOptimizer/CALCPanel/CALCPanelVM.vb b/EgtBEAMWALL.ViewerOptimizer/CALCPanel/CALCPanelVM.vb index 1b5b7f72..b3d0d8e8 100644 --- a/EgtBEAMWALL.ViewerOptimizer/CALCPanel/CALCPanelVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/CALCPanel/CALCPanelVM.vb @@ -95,6 +95,12 @@ Public Class CALCPanelVM End Get End Property + Public ReadOnly Property Edit_Visibility As Visibility + Get + Return If(Map.refMainMenuVM.SelPage = Pages.VIEW AndAlso GetMainPrivateProfileInt(S_GENERAL, K_ENABLEEDIT, 0) = 1, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + Public ReadOnly Property Verify_IsEnabled As Boolean Get Return If(Map.refMainMenuVM.SelPage = Pages.VIEW, diff --git a/EgtBEAMWALL.ViewerOptimizer/CALCPanel/CalcPanelV.xaml b/EgtBEAMWALL.ViewerOptimizer/CALCPanel/CalcPanelV.xaml index a6599cd1..b6109e26 100644 --- a/EgtBEAMWALL.ViewerOptimizer/CALCPanel/CalcPanelV.xaml +++ b/EgtBEAMWALL.ViewerOptimizer/CALCPanel/CalcPanelV.xaml @@ -37,7 +37,7 @@ Style="{StaticResource ToolBar_Button}" Command="{Binding Edit_Command}" IsEnabled="{Binding Edit_IsEnabled}" - Visibility="{Binding ViewPage_Visibility}"> + Visibility="{Binding Edit_Visibility}"> + + + + - - - - - + + + - - - - - - + - + + + + + + - + diff --git a/EgtBEAMWALL.ViewerOptimizer/Project/ProjectVM.vb b/EgtBEAMWALL.ViewerOptimizer/Project/ProjectVM.vb index 66e536b3..5b210db3 100644 --- a/EgtBEAMWALL.ViewerOptimizer/Project/ProjectVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/Project/ProjectVM.vb @@ -172,6 +172,7 @@ Public Class ProjectVM Friend Sub NotifyCalcPanel_Visibility() Map.refCALCPanelVM.NotifyPropertyChanged(NameOf(Map.refCALCPanelVM.ViewPage_Visibility)) + Map.refCALCPanelVM.NotifyPropertyChanged(NameOf(Map.refCALCPanelVM.Edit_Visibility)) End Sub Private m_FreeContourManager_Visibility As Boolean = False diff --git a/EgtBEAMWALL.ViewerOptimizer/Resources/PartManager/Clock.png b/EgtBEAMWALL.ViewerOptimizer/Resources/PartManager/Clock.png new file mode 100644 index 00000000..6b7c9186 Binary files /dev/null and b/EgtBEAMWALL.ViewerOptimizer/Resources/PartManager/Clock.png differ diff --git a/EgtBEAMWALL.ViewerOptimizer/SceneHost/MySceneHostVM.vb b/EgtBEAMWALL.ViewerOptimizer/SceneHost/MySceneHostVM.vb index 629d0482..c1b7632f 100644 --- a/EgtBEAMWALL.ViewerOptimizer/SceneHost/MySceneHostVM.vb +++ b/EgtBEAMWALL.ViewerOptimizer/SceneHost/MySceneHostVM.vb @@ -545,7 +545,10 @@ Public Class MySceneHostVM ' carico lista macchine e macchina del progetto per il pulsante Reset Macchina del CALCPanel Map.refCALCPanelVM.LoadMachineList() ElseIf ProjectType = ProjectType.PROD Then - Map.refProdManagerVM.m_MruFiles.Add(sFile) + ' se salvato, carico progetto in lista mru + If Not Map.refProdManagerVM.TempCurrProd.bIsNew Then + Map.refProdManagerVM.m_MruFiles.Add(sFile) + End If ' imposto macchina del progetto Map.refMachinePanelVM.SelectedMachine = If(Not IsNothing(Map.refProdManagerVM.TempCurrProd), Map.refMachinePanelVM.MachineList.FirstOrDefault(Function(x) x.Name = Map.refProdManagerVM.TempCurrProd.sMachine),