refresh core x NcThermo

This commit is contained in:
Samuele Locatelli
2020-05-19 20:11:25 +02:00
parent 56d7a4e592
commit ecd6f52267
2 changed files with 47 additions and 27 deletions
+4 -1
View File
@@ -215,7 +215,10 @@ namespace CMS_CORE_Library.Models
{
public readonly MEMORY_TYPE MemType;
public readonly int Address;
public readonly int SubAddress; // Only for Siemens
public readonly int SubAddress;
/// <summary>
/// Memory size (in byte)
/// </summary>
public readonly int Size;
public MEMORY_CELL(MEMORY_TYPE MType, int Addr, int SubAddr, int Sz)
+43 -26
View File
@@ -484,11 +484,14 @@ namespace CMS_CORE_Library.S7Net
catch (Exception ex)
{
return ManageException(ex);
}
return NO_ERROR;
}
#endif
return FUNCTION_NOT_ALLOWED_ERROR;
var lang = GetCultureFromThreeLetter("eng");
if (lang != null)
languages.Add(lang);
return NO_ERROR;
}
#endregion Contructor & global methods
@@ -917,7 +920,7 @@ namespace CMS_CORE_Library.S7Net
softKeyStatusMemory.MemType,
softKeyStatusMemory.Address,
softKeyStatusMemory.SubAddress,
memorySizeToRead / 1, // 4,
memorySizeToRead / 4,
ref readValues);
if (cmsError.IsError())
@@ -2126,16 +2129,16 @@ namespace CMS_CORE_Library.S7Net
public override CmsError PLC_RGaugeData(ref GaugeModel gaugeData)
{
List<int> Values = new List<int>();
// TODO FIXME quando disponibile memoria...
gaugeData = new GaugeModel()
{
TimeAdv = 1,
Power = 2,
Vacuum = 3,
Air = 4,
};
#if false
CmsError cmsError = MEM_RWIntegerList(R, 1, MACHINE_GAUGE_DATA.MemType, MACHINE_GAUGE_DATA.Address, MACHINE_GAUGE_DATA.SubAddress, MACHINE_GAUGE_DATA.Size, ref Values);
//// TODO FIXME quando disponibile memoria...
//gaugeData = new GaugeModel()
//{
// TimeAdv = 1,
// Power = 2,
// Vacuum = 3,
// Air = 4,
//};
#if true
CmsError cmsError = MEM_RWIntegerList(R, 1, MACHINE_GAUGE_DATA.MemType, MACHINE_GAUGE_DATA.Address, MACHINE_GAUGE_DATA.SubAddress, MACHINE_GAUGE_DATA.Size / 4, ref Values);
if (cmsError.IsError())
return cmsError;
@@ -2146,7 +2149,7 @@ namespace CMS_CORE_Library.S7Net
Power = Values[1],
Vacuum = Values[2],
Air = Values[3],
};
};
#endif
return NO_ERROR;
@@ -2671,8 +2674,10 @@ namespace CMS_CORE_Library.S7Net
CmsError cmsError = MEM_RWByteList(bWrite, Process, MemType, MemTable, MemIndex, MemByte, 1, ref ListValue);
if (cmsError.IsError())
return cmsError;
Value = ListValue.First();
if (ListValue.Count > 0)
{
Value = ListValue.First();
}
return NO_ERROR;
}
@@ -2740,7 +2745,7 @@ namespace CMS_CORE_Library.S7Net
{
List<int> ListValue = new List<int>() { Value };
//uses the List method with one-element list
// uses the List method with one-element list, reading int32 (4byte) data...
CmsError cmsError = MEM_RWIntegerList(bWrite, Process, MemType, MemTable, MemIndex, 1, ref ListValue);
if (cmsError.IsError())
return cmsError;
@@ -2959,6 +2964,18 @@ namespace CMS_CORE_Library.S7Net
return NO_ERROR;
}
/// <summary>
/// Lettura lista di interi
/// </summary>
/// <param name="bWrite"></param>
/// <param name="Process"></param>
/// <param name="MemType"></param>
/// <param name="MemTable"></param>
/// <param name="MemIndex"></param>
/// <param name="Number">numero di INT 32 da leggere (byte/4)</param>
/// <param name="Values"></param>
/// <returns></returns>
public override CmsError MEM_RWIntegerList(bool bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, int Number, ref List<int> Values)
{
//Check if the NC is Connected
@@ -3000,18 +3017,18 @@ namespace CMS_CORE_Library.S7Net
byte[] memByteRead = null;
try
{
memByteRead = currPLC.ReadBytes(DataType.DataBlock, MemTable, MemIndex, Number);
memByteRead = currPLC.ReadBytes(DataType.DataBlock, MemTable, MemIndex, Number * 4);
}
catch
{
return PLC_MEM_CONF_ERROR;
}
// converto a word!
int shortVal = 0;
int intVal = 0;
for (int i = 0; i < memByteRead.Length / 4; i++)
{
shortVal = S7.Net.Types.DInt.FromByteArray(memByteRead.Skip(4 * i).Take(4).ToArray());
Values.Add(shortVal);
intVal = S7.Net.Types.DInt.FromByteArray(memByteRead.Skip(4 * i).Take(4).ToArray());
Values.Add(intVal);
}
}
@@ -4243,7 +4260,7 @@ namespace CMS_CORE_Library.S7Net
internal static MEMORY_CELL NEW_MATR_MACC = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 604, 6720, 4);
// generic machine gauge data
internal static MEMORY_CELL MACHINE_GAUGE_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 605, 6, 8);
internal static MEMORY_CELL MACHINE_GAUGE_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 605, 6, 16);
internal static MEMORY_CELL NC_WATCHDOG = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 0, 1);
@@ -4253,8 +4270,8 @@ namespace CMS_CORE_Library.S7Net
internal static MEMORY_CELL FUNCTION_ACCESS = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 6, 8);
internal static MEMORY_CELL PRE_POST_POWER_ON = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 6542, 1);
internal static MEMORY_CELL PRE_POST_POWER_ON_CLICKABLE = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 2576, 2);
internal static MEMORY_CELL PRE_POST_POWER_ON = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 6542, 4);
//internal static MEMORY_CELL PRE_POST_POWER_ON_CLICKABLE = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 2576, 2);
internal static MEMORY_CELL PRE_POST_POWER_ON_ACK = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 2578, 2);
internal static MEMORY_CELL PRE_POST_POWER_ON_CLICKED = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 2580, 2);