Merge branch 'feature/S7Net' into develop
This commit is contained in:
@@ -649,11 +649,11 @@ namespace CMS_CORE_Library
|
||||
/// <returns></returns>
|
||||
public abstract CmsError PLC_RRecipeParamList(bool onlyRT, ref Dictionary<int, ThermoModels.RecipeParam> currParamList);
|
||||
/// <summary>
|
||||
/// Write recipe updated parameter
|
||||
/// Write recipe updated MULTIPLE parameter
|
||||
/// </summary>
|
||||
/// <param name="updtParam"></param>
|
||||
/// <returns></returns>
|
||||
public abstract CmsError PLC_WRecipeParam(ThermoModels.RecipeParam updtParam);
|
||||
public abstract CmsError PLC_WRecipeParameters(Dictionary<int, int> newParameters);
|
||||
/// <summary>
|
||||
/// Confirm/Cancel recipe modifications
|
||||
/// </summary>
|
||||
|
||||
@@ -2016,30 +2016,55 @@ namespace CMS_CORE_Library.S7Net
|
||||
return currError;
|
||||
}
|
||||
/// <summary>
|
||||
/// Write recipe updated parameter
|
||||
/// Write recipe updated MULTIPLE parameter
|
||||
/// </summary>
|
||||
/// <param name="updtParam"></param>
|
||||
/// <returns></returns>
|
||||
public override CmsError PLC_WRecipeParam(ThermoModels.RecipeParam updtParam)
|
||||
public override CmsError PLC_WRecipeParameters(Dictionary<int, int> newParameters)
|
||||
{
|
||||
// init variabili accessorie
|
||||
CmsError cmsError = NO_ERROR;
|
||||
List<byte> currMem = new List<byte>();
|
||||
int memIndex = 0;
|
||||
int packSize = 20;
|
||||
int memIndex = PARAMETER_DATA.SubAddress + (updtParam.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);
|
||||
|
||||
// leggo da PLC a array di byte di appoggio...
|
||||
cmsError = MEM_RWByteList(R, 0, PARAMETER_DATA.MemType, PARAMETER_DATA.Address, PARAMETER_DATA.SubAddress, 0, PARAMETER_DATA.Size, ref currMem);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
// converto in parametro...
|
||||
PlcParam currParam = new PlcParam(currMem.ToArray());
|
||||
// aggiorno SetpointHMI...
|
||||
currParam.SetpointHMI = (int)updtParam.SetpointHMI;
|
||||
// converto a NUOVA lista byte
|
||||
List<byte> 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;
|
||||
PlcParam currParam;
|
||||
List<byte> newMem = new List<byte>();
|
||||
// controllo SE ho dati...
|
||||
if (currMem.Count > 0)
|
||||
{
|
||||
// converto in array di byte...
|
||||
byte[] memArray = currMem.ToArray();
|
||||
// ciclo x ogni parametro x aggiornare il valore...
|
||||
foreach (var item in newParameters)
|
||||
{
|
||||
memIndex = (item.Key - 1) * packSize;
|
||||
// recupero oggetto parametri
|
||||
currParam = new PlcParam(memArray.Skip(memIndex).Take(packSize).ToArray());
|
||||
if (currParam.Id > 0)
|
||||
{
|
||||
// se servisse resetto...
|
||||
if (currParam.Id != (short)item.Key)
|
||||
currParam.Id = (short)item.Key;
|
||||
currParam.SetpointHMI = (int)item.Value;
|
||||
}
|
||||
// riconverto in byte e sostituisco...
|
||||
Buffer.BlockCopy(currParam.convertToByte(), 0, memArray, memIndex, packSize);
|
||||
}
|
||||
|
||||
// converto nuova memoria
|
||||
newMem = memArray.ToList();
|
||||
memIndex = 0;
|
||||
// SCRIVO in blocco!
|
||||
cmsError = MEM_RWByteList(W, 0, PARAMETER_DATA.MemType, PARAMETER_DATA.Address, PARAMETER_DATA.SubAddress, 0, PARAMETER_DATA.Size, ref newMem);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user