FIX S7Net block messages translation + terminated block

This commit is contained in:
Samuele Locatelli
2020-07-17 14:53:20 +02:00
parent c5a74727c9
commit 19a2b331aa
2 changed files with 10 additions and 2 deletions
+3
View File
@@ -111,6 +111,7 @@ namespace CMS_CORE_Library.Models
public bool Visible { get; set; } = false;
public bool Running { get; set; } = false;
public bool HasError { get; set; } = false;
public bool Terminated { get; set; } = false;
public override bool Equals(object obj)
{
@@ -136,6 +137,8 @@ namespace CMS_CORE_Library.Models
return false;
if (HasError != item.HasError)
return false;
if (Terminated != item.Terminated)
return false;
return true;
}
+7 -2
View File
@@ -265,7 +265,7 @@ namespace CMS_CORE_Library.S7Net
.ToDictionary(line => line[0].Trim(), line => line[1].Trim());
// Setup the Path for labels
filePath = THERMO_DICT_PATH + @"labels_" + langName + @".txt";
filePath = THERMO_DICT_PATH + @"Labels_" + langName + @".txt";
// Read From File...
dict02 = File.ReadAllLines(filePath, Encoding.Default)
@@ -2569,6 +2569,7 @@ namespace CMS_CORE_Library.S7Net
ThermoModuleList[currModBlock.Id].Visible = currModBlock.Visible;
ThermoModuleList[currModBlock.Id].Running = currModBlock.Running;
ThermoModuleList[currModBlock.Id].HasError = currModBlock.HasError;
ThermoModuleList[currModBlock.Id].Terminated = currModBlock.Terminated;
ThermoModuleList[currModBlock.Id].ActualDuration = currModBlock.ActualDuration;
ThermoModuleList[currModBlock.Id].ActualDelay = currModBlock.ActualDelay;
}
@@ -2586,7 +2587,8 @@ namespace CMS_CORE_Library.S7Net
ActualDelay = currModBlock.ActualDelay,
Visible = currModBlock.Visible,
Running = currModBlock.Running,
HasError = currModBlock.HasError
HasError = currModBlock.HasError,
Terminated = currModBlock.Terminated
});
}
catch
@@ -2673,6 +2675,7 @@ namespace CMS_CORE_Library.S7Net
public bool Visible { get; set; }
public bool Running { get; set; }
public bool HasError { get; set; }
public bool Terminated { get; set; } = false;
/// <summary>
/// Deserializzazione da byte ad oggetto ParamRT
/// </summary>
@@ -2689,6 +2692,7 @@ namespace CMS_CORE_Library.S7Net
Visible = (Stato & 1) == 1;
Running = (Stato & 2) == 2;
HasError = (Stato & 4) == 4;
Terminated = (Stato & 8) == 8;
}
/// <summary>
/// Converte un singolo item in un array di byte per scrittura su PLC S7
@@ -2701,6 +2705,7 @@ namespace CMS_CORE_Library.S7Net
Stato += (ushort)(Visible ? 1 : 0);
Stato += (ushort)(Running ? 2 : 0);
Stato += (ushort)(HasError ? 4 : 0);
Stato += (ushort)(Terminated ? 8 : 0);
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);