Merge branch 'feature/S7Net' into develop
This commit is contained in:
@@ -272,6 +272,8 @@ namespace CMS_CORE_Library
|
||||
|
||||
public abstract CmsError NC_GetTranslatedPlcMessages(string language, ref Dictionary<int, string> messages);
|
||||
|
||||
public abstract CmsError NC_GetTranslatedThermoLabels(string language, ref Dictionary<string, string> messages);
|
||||
|
||||
public abstract CmsError NC_GetAvailableLanguages(ref ICollection<CultureInfo> languages);
|
||||
|
||||
/**
|
||||
@@ -639,6 +641,16 @@ namespace CMS_CORE_Library
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public abstract CmsError PLC_WAckProdUpdate();
|
||||
/// <summary>
|
||||
/// Process start prod ack
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public abstract CmsError PLC_WAckPzProdStart();
|
||||
/// <summary>
|
||||
/// Process end prod ack
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public abstract CmsError PLC_WAckPzProdEnd();
|
||||
|
||||
/// <summary>
|
||||
/// Get current recipe parameter list
|
||||
|
||||
@@ -8,6 +8,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.ServiceModel.Channels;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using static CMS_CORE_Library.Models.DataStructures;
|
||||
@@ -41,6 +42,8 @@ namespace CMS_CORE_Library.S7Net
|
||||
|
||||
// Alarms data
|
||||
private static Dictionary<int, string> PlcMessages;
|
||||
private const string PLC_MESSAGE_PATH = "C:/CMS/S7NET/";
|
||||
private const string THERMO_DICT_PATH = @"Dict\";
|
||||
|
||||
private static ushort SelectedProcess = 1;
|
||||
|
||||
@@ -206,8 +209,6 @@ namespace CMS_CORE_Library.S7Net
|
||||
/// <returns></returns>
|
||||
public override CmsError NC_GetTranslatedPlcMessages(string language, ref Dictionary<int, string> messages)
|
||||
{
|
||||
// FIXME TODO
|
||||
#if false
|
||||
string filePath;
|
||||
try
|
||||
{
|
||||
@@ -228,14 +229,60 @@ namespace CMS_CORE_Library.S7Net
|
||||
.Where(line => line.Count() == 2)
|
||||
.ToDictionary(line => Convert.ToInt32(line[0]), line => line[1].Trim());
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ManageException(ex);
|
||||
}
|
||||
#endif
|
||||
return FUNCTION_NOT_ALLOWED_ERROR;
|
||||
return NO_ERROR;
|
||||
}
|
||||
/// <summary>
|
||||
/// Compilazione dizionario traduzioni THermo
|
||||
/// </summary>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="messages"></param>
|
||||
/// <returns></returns>
|
||||
public override CmsError NC_GetTranslatedThermoLabels(string language, ref Dictionary<string, string> messages)
|
||||
{
|
||||
string filePath;
|
||||
Dictionary<string, string> dict01 = new Dictionary<string, string>();
|
||||
Dictionary<string, string> dict02 = new Dictionary<string, string>();
|
||||
try
|
||||
{
|
||||
CultureInfo cultureInfo = CultureInfo.CreateSpecificCulture(language);
|
||||
string langName = "";
|
||||
if (cultureInfo.IsNeutralCulture)
|
||||
langName = cultureInfo.EnglishName;
|
||||
else
|
||||
langName = cultureInfo.Parent.EnglishName;
|
||||
|
||||
// Setup the Path for enums
|
||||
filePath = THERMO_DICT_PATH + @"Enums_" + language + @".txt";
|
||||
|
||||
// Read From File...
|
||||
dict01 = File.ReadAllLines(filePath, Encoding.Default)
|
||||
.Select(line => line.Split(','))
|
||||
.Where(line => line.Count() == 2)
|
||||
.ToDictionary(line => line[0].Trim(), line => line[1].Trim());
|
||||
|
||||
// Setup the Path for labels
|
||||
filePath = THERMO_DICT_PATH + @"labels_" + language + @".txt";
|
||||
|
||||
// Read From File...
|
||||
dict02 = File.ReadAllLines(filePath, Encoding.Default)
|
||||
.Select(line => line.Split(','))
|
||||
.Where(line => line.Count() == 2)
|
||||
.ToDictionary(line => line[0].Trim(), line => line[1].Trim());
|
||||
|
||||
// combine 2 dictionary...
|
||||
messages = dict01.Union(dict02).ToDictionary(d => d.Key, d => d.Value);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ManageException(ex);
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
/// <summary>
|
||||
/// Elenco lingue disponibili
|
||||
@@ -480,7 +527,7 @@ namespace CMS_CORE_Library.S7Net
|
||||
/// <returns></returns>
|
||||
public override CmsError NC_RActiveAlarms(ref List<AlarmModel> alarms)
|
||||
{
|
||||
return FUNCTION_NOT_ALLOWED_ERROR;
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -529,6 +576,7 @@ namespace CMS_CORE_Library.S7Net
|
||||
bool[] statusBits;
|
||||
int i = 0;
|
||||
List<int> readValues = new List<int>();
|
||||
List<byte> currMem = new List<byte>();
|
||||
CmsError libraryError;
|
||||
try
|
||||
{
|
||||
@@ -545,15 +593,29 @@ namespace CMS_CORE_Library.S7Net
|
||||
if (libraryError.IsError())
|
||||
return libraryError;
|
||||
|
||||
// leggo a BYTE
|
||||
libraryError = MEM_RWByteList(R, 0,
|
||||
ALARMS_STATUS.MemType,
|
||||
ALARMS_STATUS.Address,
|
||||
ALARMS_STATUS.SubAddress,
|
||||
0,
|
||||
(ALARMS_STATUS.Size), // status_bytes / 4 + data_word / 2
|
||||
ref currMem);
|
||||
|
||||
if (libraryError.IsError())
|
||||
return libraryError;
|
||||
|
||||
alarms.Clear();
|
||||
|
||||
// Convert integer array into bit array
|
||||
statusBits = IntToBits(readValues.ToArray());
|
||||
|
||||
BitArray bArray = new BitArray(currMem.ToArray());
|
||||
|
||||
for (i = 0; i < ALARMS_STATUS.Size * 8; i++)
|
||||
{
|
||||
// If alarm is active
|
||||
if (statusBits[i])
|
||||
if (bArray[i])
|
||||
{
|
||||
// Calculate matching alarm byte info address
|
||||
int dataByteAddress = (i * 16) + ALARMS_NUMBER;
|
||||
@@ -626,7 +688,7 @@ namespace CMS_CORE_Library.S7Net
|
||||
CmsError libraryError = NO_ERROR;
|
||||
|
||||
List<byte> currMem = new List<byte>();
|
||||
libraryError = MEM_RWByteList(R, 0, PRE_POST_POWER_ON.MemType, PRE_POST_POWER_ON.Address, PRE_POST_POWER_ON.SubAddress,0, 4, ref currMem);
|
||||
libraryError = MEM_RWByteList(R, 0, PRE_POST_POWER_ON.MemType, PRE_POST_POWER_ON.Address, PRE_POST_POWER_ON.SubAddress, 0, 4, ref currMem);
|
||||
|
||||
if (libraryError.IsError())
|
||||
return libraryError;
|
||||
@@ -635,7 +697,7 @@ namespace CMS_CORE_Library.S7Net
|
||||
|
||||
// Convert int into to true/false array
|
||||
//bits = IntToBits(readValue);
|
||||
var bArray = new BitArray(currMem.ToArray());
|
||||
var bArray = new BitArray(currMem.ToArray());
|
||||
bArray.CopyTo(bits, 0);
|
||||
|
||||
// Create adn set pre power on object
|
||||
@@ -1953,6 +2015,36 @@ namespace CMS_CORE_Library.S7Net
|
||||
|
||||
return libraryError;
|
||||
}
|
||||
/// <summary>
|
||||
/// Process start prod ack
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override CmsError PLC_WAckPzProdStart()
|
||||
{
|
||||
CmsError libraryError = NO_ERROR;
|
||||
|
||||
// Call ack for prod update
|
||||
libraryError = PLC_WAck(REQ_CONF_ACK, REQ_CONF_STROBE, 11);
|
||||
if (libraryError.IsError())
|
||||
return libraryError;
|
||||
|
||||
return libraryError;
|
||||
}
|
||||
/// <summary>
|
||||
/// Process end prod ack
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override CmsError PLC_WAckPzProdEnd()
|
||||
{
|
||||
CmsError libraryError = NO_ERROR;
|
||||
|
||||
// Call ack for prod update
|
||||
libraryError = PLC_WAck(REQ_CONF_ACK, REQ_CONF_STROBE, 12);
|
||||
if (libraryError.IsError())
|
||||
return libraryError;
|
||||
|
||||
return libraryError;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// read current recipe parameter list
|
||||
@@ -4349,7 +4441,7 @@ namespace CMS_CORE_Library.S7Net
|
||||
memByteRead = currMem.Skip(4).Take(22).ToArray();
|
||||
outVal = "";
|
||||
numByte = memByteRead[1];
|
||||
for (int i = 2; i < numByte+2; i++)
|
||||
for (int i = 2; i < numByte + 2; i++)
|
||||
{
|
||||
outVal += Char.ConvertFromUtf32(memByteRead[i]);
|
||||
}
|
||||
@@ -4358,7 +4450,7 @@ namespace CMS_CORE_Library.S7Net
|
||||
memByteRead = currMem.Skip(26).Take(18).ToArray();
|
||||
outVal = "";
|
||||
numByte = memByteRead[1];
|
||||
for (int i = 2; i < numByte+2; i++)
|
||||
for (int i = 2; i < numByte + 2; i++)
|
||||
{
|
||||
outVal += Char.ConvertFromUtf32(memByteRead[i]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user