fix parametro lenght stringa...

This commit is contained in:
Samuele E. Locatelli
2019-11-13 21:58:41 +01:00
parent 4a8ae76ea7
commit 8a67bd6a6e
2 changed files with 55 additions and 18 deletions
+54 -17
View File
@@ -52,6 +52,52 @@ namespace IOB_WIN
#region area metodi lettura/Scrittura
/// <summary>
/// Inserimento/aggiornamento chiavi/valore in currProdData
/// </summary>
/// <param name="chiave"></param>
/// <param name="valore"></param>
public void upsertKey(string chiave, string valore)
{
if (currProdData.ContainsKey(chiave))
{
currProdData[chiave] = valore;
}
else
{
currProdData.Add(chiave, valore);
}
}
/// <summary>
/// Converte direttamente un valore stringa su un oggetto byte[] (senza limitazioni di dimensione)
/// </summary>
/// <param name="valore"></param>
/// <param name="maxLenght">Dimensione massima ammessa per la stringa</param>
/// <returns></returns>
public byte[] stringToByte(string valore, int maxLenght)
{
byte[] answ = new byte[1];
byte[] stringPar = new byte[2];
byte[] strByte = S7.Net.Types.String.ToByteArray(valore);
int shiftStrByte = writePre ? 2 : 0;
int byteLen = strByte.Length <= maxLenght ? strByte.Length : maxLenght;
if (writePre)
{
// tolgo 2 alla lunghezza... SE > 2
if (byteLen > 2)
{
byteLen = byteLen - 2;
}
// MAX LUN
stringPar[1] = (byte)maxLenght;
// LUNGH STRING
stringPar[0] = (byte)byteLen;
Buffer.BlockCopy(stringPar, 0, answ, 0, shiftStrByte);
}
Buffer.BlockCopy(strByte, 0, answ, shiftStrByte, byteLen);
return answ;
}
/// <summary>
/// Salvo in memblock il valore stringa indicato con formattazione siemens
/// </summary>
@@ -111,22 +157,6 @@ namespace IOB_WIN
}
}
/// <summary>
/// Inserimento/aggiornamento chiavi/valore in currProdData
/// </summary>
/// <param name="chiave"></param>
/// <param name="valore"></param>
public void upsertKey(string chiave, string valore)
{
if (currProdData.ContainsKey(chiave))
{
currProdData[chiave] = valore;
}
else
{
currProdData.Add(chiave, valore);
}
}
/// <summary>
/// Salvo in memblock il valore Int indicato con formattazione siemens
/// </summary>
@@ -1159,7 +1189,14 @@ namespace IOB_WIN
saveRealOnMemBlock(ref MemBlock, 0, currMem.value);
break;
case plcDataType.String:
saveStringOnMemBlock(ref MemBlock, 0, currMem.value.Length, currMem.value);
if (true)
{
saveStringOnMemBlock(ref MemBlock, 0, currMem.size, currMem.value);
}
else
{
MemBlock = stringToByte(currMem.value, currMem.size);
}
break;
default:
break;
Vendored
+1 -1
View File
@@ -16,7 +16,7 @@ pipeline {
/* calcolo numero versione... diverso x branch MASTER/DEVELOP */
script {
withEnv(['NEXT_BUILD_NUMBER=520']) {
withEnv(['NEXT_BUILD_NUMBER=521']) {
// env.versionNumber = VersionNumber(versionNumberString : '2.4.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true)
env.versionNumber = VersionNumber(versionNumberString : '2.4.${BUILD_DATE_FORMATTED, "yyMM"}.${BUILDS_ALL_TIME}', projectStartDate : '2006-01-01', skipFailedBuilds: true, overrideBuildsAllTime: '${NEXT_BUILD_NUMBER}')
env.APP_NAME = 'MAPO-IOB-WIN'