diff --git a/CMS_CORE_Library/Models/DataStructures.cs b/CMS_CORE_Library/Models/DataStructures.cs
index ea484d1..fecec47 100644
--- a/CMS_CORE_Library/Models/DataStructures.cs
+++ b/CMS_CORE_Library/Models/DataStructures.cs
@@ -171,6 +171,7 @@ namespace CMS_CORE_Library.Models
public static CmsError NO_ERROR = new CmsError(CMS_ERROR_CODES.OK, "");
public static CmsError NOT_CONNECTED_ERROR = new CmsError(CMS_ERROR_CODES.NOT_CONNECTED, "error_not_connected");
+ public static CmsError NOT_FOUND_ERROR = new CmsError(CMS_ERROR_CODES.INTERNAL_ERROR, "error_not_found");
public static CmsError PROC_NOT_FOUND_ERROR = new CmsError(CMS_ERROR_CODES.FUNCTION_NOT_ALLOWED, "error_process_not_found");
public static CmsError FUNCTION_NOT_ALLOWED_ERROR = new CmsError(CMS_ERROR_CODES.FUNCTION_NOT_ALLOWED, "error_function_not_allowed");
public static CmsError BIT_NOT_IN_RANGE_ERROR = new CmsError(CMS_ERROR_CODES.BIT_NOT_IN_RANGE, "error_bit_not_in_range");
diff --git a/CMS_CORE_Library/Models/ThermoModels.cs b/CMS_CORE_Library/Models/ThermoModels.cs
index 52a9732..324a9e4 100644
--- a/CMS_CORE_Library/Models/ThermoModels.cs
+++ b/CMS_CORE_Library/Models/ThermoModels.cs
@@ -147,9 +147,11 @@ namespace CMS_CORE_Library.Models
public class WarmerChannel
{
public int IdChannel { get; set; } = 0;
+ public double SetpointRecipe { get; set; } = 0;
public double SetpointThermoCam { get; set; } = 0;
public double SetpointPLC { get; set; } = 0;
public byte ChStatus { get; set; } = 0;
+ public double CurrAct { get; set; } = 0;
public byte PercAct { get; set; } = 0;
public override bool Equals(object obj)
@@ -160,12 +162,16 @@ namespace CMS_CORE_Library.Models
if (IdChannel != item.IdChannel)
return false;
+ if (SetpointRecipe != item.SetpointRecipe)
+ return false;
if (SetpointThermoCam != item.SetpointThermoCam)
return false;
if (SetpointPLC != item.SetpointPLC)
return false;
if (ChStatus != item.ChStatus)
return false;
+ if (CurrAct != item.CurrAct)
+ return false;
if (PercAct != item.PercAct)
return false;
diff --git a/CMS_CORE_Library/NcThermo.cs b/CMS_CORE_Library/NcThermo.cs
index f01dbc4..cc622b8 100644
--- a/CMS_CORE_Library/NcThermo.cs
+++ b/CMS_CORE_Library/NcThermo.cs
@@ -653,6 +653,18 @@ namespace CMS_CORE_Library
///
public abstract CmsError PLC_RWarmerChannelList(ref Dictionary currWarmerChannelList);
///
+ /// Set current Warmers Channels setpoints
+ ///
+ ///
+ ///
+ public abstract CmsError PLC_WWarmerChSetpoints(Dictionary currWarmerChannelList);
+ ///
+ /// Set current Warmers Channels setup data
+ ///
+ ///
+ ///
+ public abstract CmsError PLC_WWarmerChData(Dictionary currWarmerChannelList);
+ ///
/// Read power gauge data
///
/// Compatibility: S7Net
diff --git a/CMS_CORE_Library/S7Net/Nc_S7Net.cs b/CMS_CORE_Library/S7Net/Nc_S7Net.cs
index 931401e..53f2902 100644
--- a/CMS_CORE_Library/S7Net/Nc_S7Net.cs
+++ b/CMS_CORE_Library/S7Net/Nc_S7Net.cs
@@ -1912,6 +1912,8 @@ namespace CMS_CORE_Library.S7Net
// refresh % attuale
refreshRiscPerc();
// refresh setpoint PLC
+ refreshRiscActCurr();
+ // refresh setpoint PLC
refreshRiscSetpointPLC();
// refresh setpoint termocamera ???
refreshRiscSetpointTermoCam();
@@ -2005,7 +2007,7 @@ namespace CMS_CORE_Library.S7Net
}
///
- /// Refresh recip parameters RT
+ /// Refresh recipE parameters RT
///
protected void refreshMemRecipeParameterRT()
{
@@ -2368,6 +2370,42 @@ namespace CMS_CORE_Library.S7Net
// leggo DB500 x area Ich
List currMem = new List();
+ // leggo da PLC a array di byte di appoggio...
+ CmsError cmsError = MEM_RWByteList(R, 0, RISC_CHP_DATA.MemType, RISC_CHP_DATA.Address, RISC_CHP_DATA.SubAddress, 0, RISC_CHP_DATA.Size, ref currMem);
+
+ // copio! controllo SE ho dati...
+ if (currMem.Count > 0)
+ {
+ // converto a blocchi di 8 byte...
+ byte[] memArray = currMem.ToArray();
+ double currVal = 0;
+ for (int i = 0; i < RISC_CHP_DATA.Size / 4; i++)
+ {
+ currVal = S7.Net.Types.Double.FromByteArray(memArray.Skip(4 * i).Take(4).ToArray());
+ // cerco id + 1 (su memoria è base 0)
+ if (ThermoWarmChannels.ContainsKey(i + 1))
+ {
+ ThermoWarmChannels[i + 1].SetpointPLC = currVal;
+ }
+ else
+ {
+ ThermoWarmChannels.Add(i + 1, new ThermoModels.WarmerChannel()
+ {
+ IdChannel = i + 1,
+ SetpointPLC = currVal
+ });
+ }
+ }
+ }
+ }
+ ///
+ /// Refresh Canali Riscaldi: actual current PLC
+ ///
+ private void refreshRiscActCurr()
+ {
+ // leggo DB500 x area Ich
+ List currMem = new List();
+
// leggo da PLC a array di byte di appoggio...
CmsError cmsError = MEM_RWByteList(R, 0, RISC_ICH_DATA.MemType, RISC_ICH_DATA.Address, RISC_ICH_DATA.SubAddress, 0, RISC_ICH_DATA.Size, ref currMem);
@@ -2383,14 +2421,14 @@ namespace CMS_CORE_Library.S7Net
// cerco id + 1 (su memoria è base 0)
if (ThermoWarmChannels.ContainsKey(i + 1))
{
- ThermoWarmChannels[i + 1].SetpointPLC = currVal;
+ ThermoWarmChannels[i + 1].CurrAct = currVal;
}
else
{
ThermoWarmChannels.Add(i + 1, new ThermoModels.WarmerChannel()
{
IdChannel = i + 1,
- SetpointPLC = currVal
+ CurrAct = currVal
});
}
}
@@ -2465,6 +2503,66 @@ namespace CMS_CORE_Library.S7Net
}
}
+ ///
+ /// Write Warmers channels load data
+ ///
+ ///
+ ///
+ public override CmsError PLC_WWarmerChSetpoints(Dictionary updtCh)
+ {
+ // memory area
+ List newMem = new List();
+
+ // per fare swapt faccio 2 alla volta e inverto ordine...
+ for (int i = 0; i < RISC_CHP_DATA.Size / 2; i++)
+ {
+ // aggiungo bit dispari
+ newMem.Add((byte)updtCh[i * 2 + 1]);
+ // aggiungo bit pari
+ newMem.Add((byte)updtCh[i * 2]);
+ }
+
+ // error in write WARM area...
+#if false
+ // write!
+ CmsError cmsError = MEM_RWByteList(W, 0, RISC_CHP_DATA.MemType, RISC_CHP_DATA.Address, RISC_CHP_DATA.SubAddress, 0, RISC_CHP_DATA.Size, ref newMem);
+ if (cmsError.IsError())
+ return cmsError;
+#endif
+
+ return NO_ERROR;
+ }
+ ///
+ /// Write Warmers channels setup parameters
+ ///
+ ///
+ ///
+ public override CmsError PLC_WWarmerChData(Dictionary updtCh)
+ {
+ // FIXME TODO
+#if false
+ // init variabili accessorie
+ List currMem = new List();
+ int packSize = 20;
+ int memIndex = PARAMETER_DATA.SubAddress + (updtCh.Id - 1) * packSize;
+ // leggo in primis il parametro che mi richiedono
+ CmsError cmsError = MEM_RWByteList(R, 0, PARAMETER_DATA.MemType, PARAMETER_DATA.Address, memIndex, 0, packSize, ref currMem);
+ if (cmsError.IsError())
+ return cmsError;
+
+ // converto in parametro...
+ PlcParam currParam = new PlcParam(currMem.ToArray());
+ // aggiorno SetpointHMI...
+ currParam.SetpointHMI = (int)updtCh.SetpointHMI;
+ // converto a NUOVA lista byte
+ List newMem = currParam.convertToByte().ToList();
+ cmsError = MEM_RWByteList(W, 0, PARAMETER_DATA.MemType, PARAMETER_DATA.Address, memIndex, 0, packSize, ref newMem);
+ if (cmsError.IsError())
+ return cmsError;
+#endif
+
+ return NO_ERROR;
+ }
#endregion
diff --git a/SiemensS7/Siemens-S7-Test/TestMainForm.cs b/SiemensS7/Siemens-S7-Test/TestMainForm.cs
index 55bc384..e139812 100644
--- a/SiemensS7/Siemens-S7-Test/TestMainForm.cs
+++ b/SiemensS7/Siemens-S7-Test/TestMainForm.cs
@@ -219,7 +219,12 @@ namespace Siemens_S7_Test
{
sw.Restart();
// eseguo test
- memByteRead = currPLC.ReadBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, numByte);
+ try
+ {
+ memByteRead = currPLC.ReadBytes(DataType.DataBlock, memoria.DbNum, memoria.indiceMem, numByte);
+ }
+ catch
+ { }
sw.Stop();
// salvo risultati
PerfStats.addValue((double)sw.ElapsedMilliseconds);