Fix reading of the scada values

This commit is contained in:
Lucio Maranta
2019-01-22 14:14:21 +01:00
parent e52e9128e8
commit b1df676ccb
+4 -4
View File
@@ -2426,7 +2426,7 @@ namespace Step.NC
// Cycle through elements, use the max number of elements between layer components in order to be optimized
for (int i = 0; i < GetMaxCountBetweenLayerComponents(layer); i++)
{
if (layer.Buttons.ElementAt(i) != null)
if (layer.Buttons.ElementAtOrDefault(i) != null)
{
// Read enabled from PLC
cmsError = numericalControl.PLC_RScadaValue(layer.Buttons[i].Status.MemEnabledIndex, SCADA_MEM_TYPE.BOOL, ref val);
@@ -2440,7 +2440,7 @@ namespace Step.NC
});
}
if (layer.Images.ElementAt(i) != null)
if (layer.Images.ElementAtOrDefault(i) != null)
{
// Read isVisible from PLC
cmsError = numericalControl.PLC_RScadaValue(layer.Images[i].Status.MemVisibleIndex, SCADA_MEM_TYPE.BOOL, ref val);
@@ -2454,7 +2454,7 @@ namespace Step.NC
});
}
if (layer.ProgressBars.ElementAt(i) != null)
if (layer.ProgressBars.ElementAtOrDefault(i) != null)
{
// Read value from PLC
cmsError = numericalControl.PLC_RScadaValue(layer.ProgressBars[i].MemValueIndex, SCADA_MEM_TYPE.BYTE, ref val);
@@ -2468,7 +2468,7 @@ namespace Step.NC
});
}
if (layer.Inputs.ElementAt(i) != null && layer.Inputs[i].Status.Action == "read")
if (layer.Inputs.ElementAtOrDefault(i) != null && layer.Inputs[i].Status.Action == "read")
{
// Read isVisible from PLC
cmsError = numericalControl.PLC_RScadaValue(layer.Inputs[i].Status.MemEnabledIndex, SCADA_MEM_TYPE.BOOL, ref val);