Completed ModBlock methods
This commit is contained in:
@@ -631,7 +631,7 @@ namespace CMS_CORE_Library.Models
|
||||
public int ActualDuration { get; set; } = 0;
|
||||
public int EstimatedDelay { get; set; } = 0;
|
||||
public int EstimatedDuration { get; set; } = 0;
|
||||
public List<ushort> PrecedingId { get; set; } = new List<ushort>();
|
||||
public List<short> PrecedingId { get; set; } = new List<short>();
|
||||
public bool Visible { get; set; } = false;
|
||||
public bool Running { get; set; } = false;
|
||||
public bool HasError { get; set; } = false;
|
||||
|
||||
@@ -1923,7 +1923,9 @@ namespace CMS_CORE_Library.S7Net
|
||||
{
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refresh recip parameters RT
|
||||
/// </summary>
|
||||
protected void refreshMemRecipeParameterRT()
|
||||
{
|
||||
List<byte> currMem = new List<byte>();
|
||||
@@ -1959,6 +1961,9 @@ namespace CMS_CORE_Library.S7Net
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Refresh recipe parameters
|
||||
/// </summary>
|
||||
protected void refreshMemRecipeParameter()
|
||||
{
|
||||
List<byte> currMem = new List<byte>();
|
||||
@@ -2081,7 +2086,9 @@ namespace CMS_CORE_Library.S7Net
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refresh ModuleBlock RT
|
||||
/// </summary>
|
||||
protected void refreshMemModBlockParameterRT()
|
||||
{
|
||||
List<byte> currMem = new List<byte>();
|
||||
@@ -2112,27 +2119,30 @@ namespace CMS_CORE_Library.S7Net
|
||||
}
|
||||
else
|
||||
{
|
||||
ThermoModuleList.Add(currModBlock.Id, new ModuleBlock() {
|
||||
ThermoModuleList.Add(currModBlock.Id, new ModuleBlock()
|
||||
{
|
||||
Id = currModBlock.Id,
|
||||
ActualDuration = currModBlock.ActualDuration,
|
||||
ActualDelay = currModBlock.ActualDelay,
|
||||
Visible = currModBlock.Visible,
|
||||
Running = currModBlock.Running,
|
||||
HasError = currModBlock.HasError
|
||||
Visible = currModBlock.Visible,
|
||||
Running = currModBlock.Running,
|
||||
HasError = currModBlock.HasError
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Refresh ModuleBlock
|
||||
/// </summary>
|
||||
protected void refreshMemModBlockParameter()
|
||||
{
|
||||
#if false
|
||||
List<byte> currMem = new List<byte>();
|
||||
int packSize = 20;
|
||||
int packSize = 18;
|
||||
|
||||
// leggo da PLC a array di byte di appoggio...
|
||||
CmsError cmsError = MEM_RWByteList(R, 0, PARAMETER_DATA.MemType, PARAMETER_DATA.Address, PARAMETER_DATA.SubAddress, 0, PARAMETER_DATA.Size, ref currMem);
|
||||
CmsError cmsError = MEM_RWByteList(R, 0, MODULE_DATA.MemType, MODULE_DATA.Address, MODULE_DATA.SubAddress, 0, MODULE_DATA.Size, ref currMem);
|
||||
|
||||
|
||||
// controllo SE ho dati...
|
||||
@@ -2140,29 +2150,37 @@ namespace CMS_CORE_Library.S7Net
|
||||
{
|
||||
// converto a blocchi di 8 byte...
|
||||
byte[] memArray = currMem.ToArray();
|
||||
for (int i = 0; i < PARAMETER_DATA.Size / packSize; i++)
|
||||
for (int i = 0; i < MODULE_DATA.Size / packSize; i++)
|
||||
{
|
||||
PlcParam currParam = new PlcParam(memArray.Skip(i * packSize).Take(packSize).ToArray());
|
||||
PlcModBlock currModBlock = new PlcModBlock(memArray.Skip(i * packSize).Take(packSize).ToArray());
|
||||
// calcolo lista PrecId
|
||||
List<short> PrecId = new List<short>();
|
||||
PrecId.Add(currModBlock.PrevId_01);
|
||||
PrecId.Add(currModBlock.PrevId_02);
|
||||
PrecId.Add(currModBlock.PrevId_03);
|
||||
// solo se ID > 0...
|
||||
if (currParam.Id > 0)
|
||||
if (currModBlock.Id > 0)
|
||||
{
|
||||
// update oggetto thermoParamList...
|
||||
if (ThermoParamList.ContainsKey(currParam.Id))
|
||||
if (ThermoModuleList.ContainsKey(currModBlock.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;
|
||||
ThermoModuleList[currModBlock.Id].EstimatedDelay = currModBlock.EstimDelay;
|
||||
ThermoModuleList[currModBlock.Id].EstimatedDuration = currModBlock.EstimDuration;
|
||||
ThermoModuleList[currModBlock.Id].PrecedingId = PrecId;
|
||||
}
|
||||
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 });
|
||||
ThermoModuleList.Add(currModBlock.Id, new ModuleBlock()
|
||||
{
|
||||
Id = currModBlock.Id,
|
||||
EstimatedDelay = currModBlock.EstimDelay,
|
||||
EstimatedDuration = currModBlock.EstimDuration,
|
||||
PrecedingId = PrecId
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Oggetto Modulo Blocco RT da PLC
|
||||
@@ -2203,7 +2221,7 @@ namespace CMS_CORE_Library.S7Net
|
||||
Stato += (ushort)(Visible ? 1 : 0);
|
||||
Stato += (ushort)(Running ? 2 : 0);
|
||||
Stato += (ushort)(HasError ? 4 : 0);
|
||||
byte[] answ = new byte[8];
|
||||
byte[] answ = new byte[12];
|
||||
Buffer.BlockCopy(S7.Net.Types.Int.ToByteArray(Id), 0, answ, 0, 2);
|
||||
Buffer.BlockCopy(S7.Net.Types.DInt.ToByteArray(ActualDuration), 0, answ, 2, 4);
|
||||
Buffer.BlockCopy(S7.Net.Types.DInt.ToByteArray(ActualDelay), 0, answ, 6, 4);
|
||||
@@ -2217,11 +2235,11 @@ namespace CMS_CORE_Library.S7Net
|
||||
protected class PlcModBlock
|
||||
{
|
||||
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;
|
||||
public int EstimDuration { get; set; } = 0;
|
||||
public int EstimDelay { get; set; } = 0;
|
||||
public short PrevId_01 { get; set; } = 0;
|
||||
public short PrevId_02 { get; set; } = 0;
|
||||
public short PrevId_03 { get; set; } = 0;
|
||||
/// <summary>
|
||||
/// Deserializzazione da byte ad oggetto Param
|
||||
/// </summary>
|
||||
@@ -2230,11 +2248,11 @@ namespace CMS_CORE_Library.S7Net
|
||||
{
|
||||
// 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());
|
||||
EstimDuration = S7.Net.Types.DInt.FromByteArray(rawData.Skip(2).Take(4).ToArray());
|
||||
EstimDelay = S7.Net.Types.DInt.FromByteArray(rawData.Skip(6).Take(4).ToArray());
|
||||
PrevId_01 = S7.Net.Types.Int.FromByteArray(rawData.Skip(12).Take(2).ToArray());
|
||||
PrevId_02 = S7.Net.Types.Int.FromByteArray(rawData.Skip(14).Take(2).ToArray());
|
||||
PrevId_03 = S7.Net.Types.Int.FromByteArray(rawData.Skip(16).Take(2).ToArray());
|
||||
}
|
||||
/// <summary>
|
||||
/// Converte un singolo item in un array di byte per scrittura su PLC S7
|
||||
@@ -2242,13 +2260,13 @@ namespace CMS_CORE_Library.S7Net
|
||||
/// <returns></returns>
|
||||
public byte[] convertToByte()
|
||||
{
|
||||
byte[] answ = new byte[20];
|
||||
byte[] answ = new byte[18];
|
||||
Buffer.BlockCopy(S7.Net.Types.Int.ToByteArray(Id), 0, answ, 0, 2);
|
||||
Buffer.BlockCopy(S7.Net.Types.DInt.ToByteArray(SetpointHMI), 0, answ, 2, 4);
|
||||
Buffer.BlockCopy(S7.Net.Types.DInt.ToByteArray(SetpointPLC), 0, answ, 6, 4);
|
||||
Buffer.BlockCopy(S7.Net.Types.DInt.ToByteArray(ValMax), 0, answ, 10, 4);
|
||||
Buffer.BlockCopy(S7.Net.Types.DInt.ToByteArray(ValMin), 0, answ, 14, 4);
|
||||
Buffer.BlockCopy(S7.Net.Types.Word.ToByteArray(UnitMeasure), 0, answ, 18, 2);
|
||||
Buffer.BlockCopy(S7.Net.Types.DInt.ToByteArray(EstimDuration), 0, answ, 2, 4);
|
||||
Buffer.BlockCopy(S7.Net.Types.DInt.ToByteArray(EstimDelay), 0, answ, 6, 4);
|
||||
Buffer.BlockCopy(S7.Net.Types.DInt.ToByteArray(PrevId_01), 0, answ, 12, 2);
|
||||
Buffer.BlockCopy(S7.Net.Types.DInt.ToByteArray(PrevId_02), 0, answ, 14, 2);
|
||||
Buffer.BlockCopy(S7.Net.Types.DInt.ToByteArray(PrevId_03), 0, answ, 16, 2);
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user