diff --git a/MTC_Adapter/SCMA/AdapterPLC/CMS/EsaKosmos.cs b/MTC_Adapter/SCMA/AdapterPLC/CMS/EsaKosmos.cs index ed159df..f76462f 100644 --- a/MTC_Adapter/SCMA/AdapterPLC/CMS/EsaKosmos.cs +++ b/MTC_Adapter/SCMA/AdapterPLC/CMS/EsaKosmos.cs @@ -500,9 +500,34 @@ namespace SCMA.AdapterPLC.CMS // leggo e salvo allarmi ALM, TUTTI!!! byte[] tabDatiAlarm = new byte[1024]; + // calcolo limite x non copiare oltre livello allarmi disponibili... + int nByteAlarm = currGateway.AlarmFlags.Length; for (int i = 0; i < 32; i++) { - Buffer.BlockCopy(BitConverter.GetBytes(ncDevice.SCMA_MMan_ALM.data[i]), 0, currGateway.AlarmFlags, i * 4, 4); + if ((i+1) * 4 > nByteAlarm) + { + // copio un subset di byte + int nByte = nByteAlarm - (i* 4); + try + { + Buffer.BlockCopy(BitConverter.GetBytes(ncDevice.SCMA_MMan_ALM.data[i]), 0, currGateway.AlarmFlags, i * 4, nByte); + } + catch (Exception exc) + { } + + // esco + break; + } + else + { + // copio 4 byte + try + { + Buffer.BlockCopy(BitConverter.GetBytes(ncDevice.SCMA_MMan_ALM.data[i]), 0, currGateway.AlarmFlags, i * 4, 4); + } + catch (Exception exc) + { } + } } // leggo e salvo Counters CNT diff --git a/MTC_Adapter/SCMA/AdapterPLC/Generic.cs b/MTC_Adapter/SCMA/AdapterPLC/Generic.cs index 843270f..de16a6b 100644 --- a/MTC_Adapter/SCMA/AdapterPLC/Generic.cs +++ b/MTC_Adapter/SCMA/AdapterPLC/Generic.cs @@ -4159,13 +4159,16 @@ namespace SCMA.AdapterPLC { if (_maintDataMaxNum == 0) { - // prima stima - int idx = maintData.Length; - // ora ciclo... - foreach (var item in maintData) + if (maintData != null) { - int.TryParse(item.codNum, out idx); - _maintDataMaxNum = idx > _maintDataMaxNum ? idx : _maintDataMaxNum; + // prima stima + int idx = maintData.Length; + // ora ciclo... + foreach (var item in maintData) + { + int.TryParse(item.codNum, out idx); + _maintDataMaxNum = idx > _maintDataMaxNum ? idx : _maintDataMaxNum; + } } } return _maintDataMaxNum; diff --git a/MTC_Adapter/SCMA/SCMA.csproj b/MTC_Adapter/SCMA/SCMA.csproj index b0bc5b4..7c3c6ba 100644 --- a/MTC_Adapter/SCMA/SCMA.csproj +++ b/MTC_Adapter/SCMA/SCMA.csproj @@ -212,7 +212,10 @@ SetupAdapter.cs - + + App.config + true + Always @@ -253,11 +256,11 @@ App.config - True + true App.config - True + true Always @@ -267,12 +270,12 @@ App.config - True + true App.config Designer - True + true @@ -343,11 +346,11 @@ App.config - True + true App.config - True + true @@ -432,7 +435,7 @@ --> - + @@ -472,11 +475,11 @@ $(SlowCheetah_NuGetImportPath) - + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + \ No newline at end of file diff --git a/MTC_Adapter/SCMA/packages.config b/MTC_Adapter/SCMA/packages.config index 2e1e0dd..a4008e7 100644 --- a/MTC_Adapter/SCMA/packages.config +++ b/MTC_Adapter/SCMA/packages.config @@ -1,9 +1,9 @@  + - \ No newline at end of file diff --git a/MTC_Adapter/packages/Microsoft.VisualStudio.SlowCheetah.3.2.26/tools/Newtonsoft.Json.dll b/MTC_Adapter/packages/Microsoft.VisualStudio.SlowCheetah.3.2.26/tools/Newtonsoft.Json.dll new file mode 100644 index 0000000..be6558d Binary files /dev/null and b/MTC_Adapter/packages/Microsoft.VisualStudio.SlowCheetah.3.2.26/tools/Newtonsoft.Json.dll differ