diff --git a/CMS_CORE_Library/Demo/Nc_Demo.cs b/CMS_CORE_Library/Demo/Nc_Demo.cs index e220010..2fd4714 100644 --- a/CMS_CORE_Library/Demo/Nc_Demo.cs +++ b/CMS_CORE_Library/Demo/Nc_Demo.cs @@ -1304,6 +1304,17 @@ namespace CMS_CORE_Library.Demo /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region THERMO high level data + + public override CmsError PLC_RRecipeParamList(bool onlyRT, ref Dictionary currParamList) + { + return FUNCTION_NOT_ALLOWED_ERROR; + } + + #endregion THERMO high level data + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region PROCESS (PATH) High-level data public override CmsError PROC_RStatus(ushort ProcNumber, ref PROC_STATUS Status) diff --git a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs index e9d1b2e..f732b94 100644 --- a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs +++ b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs @@ -1599,6 +1599,17 @@ namespace CMS_CORE_Library.Fanuc /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region THERMO high level data + + public override CmsError PLC_RRecipeParamList(bool onlyRT, ref Dictionary currParamList) + { + return FUNCTION_NOT_ALLOWED_ERROR; + } + + #endregion THERMO high level data + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region PROCESS (PATH) High-level data // Get process part program data diff --git a/CMS_CORE_Library/Nc.cs b/CMS_CORE_Library/Nc.cs index 2d2abb9..e33ee33 100644 --- a/CMS_CORE_Library/Nc.cs +++ b/CMS_CORE_Library/Nc.cs @@ -615,6 +615,15 @@ namespace CMS_CORE_Library /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region THERMO high level data + + public abstract CmsError PLC_RRecipeParamList(bool onlyRT, ref Dictionary currParamList); + + + #endregion THERMO high level data + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region PROCESS (PATH, CHANNEL) data (to override) /** diff --git a/CMS_CORE_Library/Osai/Nc_Osai.cs b/CMS_CORE_Library/Osai/Nc_Osai.cs index 6ab5803..ef03a2c 100644 --- a/CMS_CORE_Library/Osai/Nc_Osai.cs +++ b/CMS_CORE_Library/Osai/Nc_Osai.cs @@ -1695,6 +1695,17 @@ namespace CMS_CORE_Library.Osai /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region THERMO high level data + + public override CmsError PLC_RRecipeParamList(bool onlyRT, ref Dictionary currParamList) + { + return FUNCTION_NOT_ALLOWED_ERROR; + } + + #endregion THERMO high level data + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region PROCESS (PATH) High-level data //Get the process status diff --git a/CMS_CORE_Library/Properties/AssemblyInfo.cs b/CMS_CORE_Library/Properties/AssemblyInfo.cs index 50a077b..8a0079f 100644 --- a/CMS_CORE_Library/Properties/AssemblyInfo.cs +++ b/CMS_CORE_Library/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build // usando l'asterisco '*' come illustrato di seguito: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.1.0.0")] -[assembly: AssemblyFileVersion("1.1.0.0")] +[assembly: AssemblyVersion("1.1.2.0")] +[assembly: AssemblyFileVersion("1.1.2.0")] diff --git a/CMS_CORE_Library/S7Net/Nc_S7Net.cs b/CMS_CORE_Library/S7Net/Nc_S7Net.cs index 5ad068e..78c5ee0 100644 --- a/CMS_CORE_Library/S7Net/Nc_S7Net.cs +++ b/CMS_CORE_Library/S7Net/Nc_S7Net.cs @@ -311,8 +311,15 @@ namespace CMS_CORE_Library.S7Net { // Set Connected to FALSE and close the sessions Connected = false; - currPLC.Close(); - + if (currPLC != null) + { + try + { + currPLC.Close(); + } + catch + { } + } return NO_ERROR; } @@ -2099,6 +2106,147 @@ namespace CMS_CORE_Library.S7Net /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region THERMO high level data + + public override CmsError PLC_RRecipeParamList(bool onlyRT, ref Dictionary currParamList) + { + // refresh dati veloci / RT + refreshMemRecipeParameterRT(); + // se richiesto NON SOLO RT faccio refresh anche dati "lenti" + if (!onlyRT) + { + refreshMemRecipeParameter(); + } + + // copio lista act in output... + currParamList = thermoParamList; + return NO_ERROR; + } + + protected void refreshMemRecipeParameterRT() + { + List currMem = new List(); + + // leggo da PLC a array di byte di appoggio... + CmsError cmsError = MEM_RWByteList(R, 0, PARAMETER_RT_DATA.MemType, PARAMETER_RT_DATA.Address, PARAMETER_RT_DATA.SubAddress, PARAMETER_RT_DATA.Size, ref currMem); + + int packSize = 8; + + // converto a blocchi di 8 byte... + byte[] memArray = currMem.ToArray(); + for (int i = 0; i < PARAMETER_RT_DATA.Size / packSize; i++) + { + PlcParamRT currParam = new PlcParamRT(memArray.Skip(i * packSize).Take(packSize).ToArray()); + // solo se ID > 0... + if (currParam.Id > 0) + { + // update oggetto thermoParamList... + if (thermoParamList.ContainsKey(currParam.Id)) + { + thermoParamList[currParam.Id].Enabled = currParam.Enabled; + thermoParamList[currParam.Id].HasError = currParam.HasError; + thermoParamList[currParam.Id].Visible = currParam.Visible; + thermoParamList[currParam.Id].ValueAct = currParam.ValueAct; + } + else + { + thermoParamList.Add(currParam.Id, new RecipeParam() { Id = currParam.Id, Enabled = currParam.Enabled, HasError = currParam.HasError, Visible = currParam.Visible, ValueAct = currParam.ValueAct }); + } + } + } + + } + protected void refreshMemRecipeParameter() + { + List currMem = new List(); + + // leggo da PLC a array di byte di appoggio... + CmsError cmsError = MEM_RWByteList(R, 0, PARAMETER_DATA.MemType, PARAMETER_DATA.Address, PARAMETER_DATA.SubAddress, PARAMETER_DATA.Size, ref currMem); + + int packSize = 20; + + // converto a blocchi di 8 byte... + byte[] memArray = currMem.ToArray(); + for (int i = 0; i < PARAMETER_DATA.Size / packSize; i++) + { + PlcParam currParam = new PlcParam(memArray.Skip(i * packSize).Take(packSize).ToArray()); + // solo se ID > 0... + if (currParam.Id > 0) + { + // update oggetto thermoParamList... + if (thermoParamList.ContainsKey(currParam.Id)) + { + thermoParamList[currParam.Id].SetpointHMI = currParam.SetpointHMI; + thermoParamList[currParam.Id].SetpointPLC = currParam.SetpointPLC; + thermoParamList[currParam.Id].ValMax = currParam.ValMax; + thermoParamList[currParam.Id].ValMin = currParam.ValMin; + thermoParamList[currParam.Id].UnitMeasure = currParam.UnitMeasure; + } + else + { + thermoParamList.Add(currParam.Id, new RecipeParam() { Id = currParam.Id, SetpointHMI = currParam.SetpointHMI, SetpointPLC = currParam.SetpointPLC, ValMax = currParam.ValMax, ValMin = currParam.ValMin, UnitMeasure = currParam.UnitMeasure }); + } + } + } + } + /// + /// Oggetto Parametro RT da PLC + /// + protected class PlcParamRT + { + public short Id { get; set; } = 0; + private ushort Stato { get; set; } = 0; + public bool Visible { get; set; } + public bool Enabled { get; set; } + public bool HasError { get; set; } + public int ValueAct { get; set; } = 0; + /// + /// Deserializzazione da byte ad oggetto ParamRT + /// + /// + public PlcParamRT(byte[] rawData) + { + // converto i dati da byte grezzi ai 3 componenti... + Id = S7.Net.Types.Int.FromByteArray(rawData.Skip(0).Take(2).ToArray()); + Stato = S7.Net.Types.Word.FromByteArray(rawData.Skip(2).Take(2).ToArray()); + ValueAct = S7.Net.Types.DInt.FromByteArray(rawData.Skip(4).Take(4).ToArray()); + // calcolo bit... + Visible = (Stato & 1) == 1; + Enabled = (Stato & 2) == 2; + HasError = (Stato & 4) == 4; + } + } + /// + /// Oggetto Parametro da PLC + /// + protected class PlcParam + { + public short Id { get; set; } = 0; + public int SetpointHMI { get; set; } = 0; + public int SetpointPLC { get; set; } = 0; + public int ValMax { get; set; } = 0; + public int ValMin { get; set; } = 0; + public ushort UnitMeasure { get; set; } = 0; + /// + /// Deserializzazione da byte ad oggetto Param + /// + /// + public PlcParam(byte[] rawData) + { + // converto i dati da byte grezzi ai 3 componenti... + Id = S7.Net.Types.Int.FromByteArray(rawData.Skip(0).Take(2).ToArray()); + SetpointHMI = S7.Net.Types.DInt.FromByteArray(rawData.Skip(2).Take(4).ToArray()); + SetpointPLC = S7.Net.Types.DInt.FromByteArray(rawData.Skip(6).Take(4).ToArray()); + ValMax = S7.Net.Types.DInt.FromByteArray(rawData.Skip(10).Take(4).ToArray()); + ValMin = S7.Net.Types.DInt.FromByteArray(rawData.Skip(14).Take(4).ToArray()); + UnitMeasure = S7.Net.Types.Word.FromByteArray(rawData.Skip(18).Take(2).ToArray()); + } + } + + #endregion + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region PROCESS-AXES (PATH) High-level data public override CmsError AXES_RInterpPosition(ushort channel, ref Dictionary axes) @@ -4053,149 +4201,10 @@ namespace CMS_CORE_Library.S7Net #endregion Subordinate Private Functions - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - #region THERMO high level data - - public CmsError PLC_RRecipeParamList(bool onlyRT, ref Dictionary currParamList) - { - // refresh dati veloci / RT - refreshMemRecipeParameterRT(); - // se richiesto NON SOLO RT faccio refresh anche dati "lenti" - if (!onlyRT) - { - refreshMemRecipeParameter(); - } - - // copio lista act in output... - currParamList = thermoParamList; - return NO_ERROR; - } - - protected void refreshMemRecipeParameterRT() - { - List currMem = new List(); - - // leggo da PLC a array di byte di appoggio... - CmsError cmsError = MEM_RWByteList(R, 0, PARAMETER_RT_DATA.MemType, PARAMETER_RT_DATA.Address, PARAMETER_RT_DATA.SubAddress, PARAMETER_RT_DATA.Size, ref currMem); - - int packSize = 8; - - // converto a blocchi di 8 byte... - byte[] memArray = currMem.ToArray(); - for (int i = 0; i < PARAMETER_RT_DATA.Size / packSize; i++) - { - PlcParamRT currParam = new PlcParamRT(memArray.Skip(i * packSize).Take(packSize).ToArray()); - // solo se ID > 0... - if (currParam.Id > 0) - { - // update oggetto thermoParamList... - if (thermoParamList.ContainsKey(currParam.Id)) - { - thermoParamList[currParam.Id].Enabled = currParam.Enabled; - thermoParamList[currParam.Id].HasError = currParam.HasError; - thermoParamList[currParam.Id].Visible = currParam.Visible; - thermoParamList[currParam.Id].ValueAct = currParam.ValueAct; - } - else - { - thermoParamList.Add(currParam.Id, new RecipeParam() { Id = currParam.Id, Enabled = currParam.Enabled, HasError = currParam.HasError, Visible = currParam.Visible, ValueAct = currParam.ValueAct }); - } - } - } - - } - protected void refreshMemRecipeParameter() - { - List currMem = new List(); - - // leggo da PLC a array di byte di appoggio... - CmsError cmsError = MEM_RWByteList(R, 0, PARAMETER_DATA.MemType, PARAMETER_DATA.Address, PARAMETER_DATA.SubAddress, PARAMETER_DATA.Size, ref currMem); - - int packSize = 20; - - // converto a blocchi di 8 byte... - byte[] memArray = currMem.ToArray(); - for (int i = 0; i < PARAMETER_DATA.Size / packSize; i++) - { - PlcParam currParam = new PlcParam(memArray.Skip(i * packSize).Take(packSize).ToArray()); - // solo se ID > 0... - if (currParam.Id > 0) - { - // update oggetto thermoParamList... - if (thermoParamList.ContainsKey(currParam.Id)) - { - thermoParamList[currParam.Id].SetpointHMI = currParam.SetpointHMI; - thermoParamList[currParam.Id].SetpointPLC = currParam.SetpointPLC; - thermoParamList[currParam.Id].ValMax = currParam.ValMax; - thermoParamList[currParam.Id].ValMin = currParam.ValMin; - thermoParamList[currParam.Id].UnitMeasure = currParam.UnitMeasure; - } - else - { - thermoParamList.Add(currParam.Id, new RecipeParam() { Id = currParam.Id, SetpointHMI = currParam.SetpointHMI, SetpointPLC = currParam.SetpointPLC, ValMax = currParam.ValMax, ValMin = currParam.ValMin, UnitMeasure = currParam.UnitMeasure }); - } - } - } - } - /// - /// Oggetto Parametro RT da PLC - /// - protected class PlcParamRT - { - public short Id { get; set; } = 0; - private ushort Stato { get; set; } = 0; - public bool Visible { get; set; } - public bool Enabled { get; set; } - public bool HasError { get; set; } - public int ValueAct { get; set; } = 0; - /// - /// Deserializzazione da byte ad oggetto ParamRT - /// - /// - public PlcParamRT(byte[] rawData) - { - // converto i dati da byte grezzi ai 3 componenti... - Id = S7.Net.Types.Int.FromByteArray(rawData.Skip(0).Take(2).ToArray()); - Stato = S7.Net.Types.Word.FromByteArray(rawData.Skip(2).Take(2).ToArray()); - ValueAct = S7.Net.Types.DInt.FromByteArray(rawData.Skip(4).Take(4).ToArray()); - // calcolo bit... - Visible = (Stato & 1) == 1; - Enabled = (Stato & 2) == 2; - HasError = (Stato & 4) == 4; - } - } - /// - /// Oggetto Parametro da PLC - /// - protected class PlcParam - { - public short Id { get; set; } = 0; - public int SetpointHMI { get; set; } = 0; - public int SetpointPLC { get; set; } = 0; - public int ValMax { get; set; } = 0; - public int ValMin { get; set; } = 0; - public ushort UnitMeasure { get; set; } = 0; - /// - /// Deserializzazione da byte ad oggetto Param - /// - /// - public PlcParam(byte[] rawData) - { - // converto i dati da byte grezzi ai 3 componenti... - Id = S7.Net.Types.Int.FromByteArray(rawData.Skip(0).Take(2).ToArray()); - SetpointHMI = S7.Net.Types.DInt.FromByteArray(rawData.Skip(2).Take(4).ToArray()); - SetpointPLC = S7.Net.Types.DInt.FromByteArray(rawData.Skip(6).Take(4).ToArray()); - ValMax = S7.Net.Types.DInt.FromByteArray(rawData.Skip(10).Take(4).ToArray()); - ValMin = S7.Net.Types.DInt.FromByteArray(rawData.Skip(14).Take(4).ToArray()); - UnitMeasure = S7.Net.Types.Word.FromByteArray(rawData.Skip(18).Take(2).ToArray()); - } - } - - #endregion } + internal static class MEMORY_ADDRESS { // Tabella DB principale diff --git a/CMS_CORE_Library/Siemens/Nc_Siemens.cs b/CMS_CORE_Library/Siemens/Nc_Siemens.cs index ea0d2ac..72e977e 100644 --- a/CMS_CORE_Library/Siemens/Nc_Siemens.cs +++ b/CMS_CORE_Library/Siemens/Nc_Siemens.cs @@ -2113,6 +2113,17 @@ namespace CMS_CORE_Library.Siemens /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region THERMO high level data + + public override CmsError PLC_RRecipeParamList(bool onlyRT, ref Dictionary currParamList) + { + return FUNCTION_NOT_ALLOWED_ERROR; + } + + #endregion THERMO high level data + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region PROCESS (PATH) High-level data // Get the process Mode