Fix osai&siemens
This commit is contained in:
@@ -55,6 +55,7 @@ namespace CMS_CORE_Library.Osai
|
||||
private const string TOOL_MANAGER_BACKUP_DIRECTORY_PATH = @"C:\CMS\Active\TMP\";
|
||||
private const string FAMILIES_FILE_NAME = @"Families";
|
||||
private const string FAM_SIZE_FILE_NAME = @"Fam_Sizes";
|
||||
|
||||
private const string MAG_POSITION_FILE_NAME = @"Mag_Positions";
|
||||
private const string SHANKS_FILE_NAME = @"Shanks";
|
||||
private const string TOOLS_FILE_NAME = @"Tools";
|
||||
@@ -458,7 +459,7 @@ namespace CMS_CORE_Library.Osai
|
||||
CmsError cmsError = MEM_RWIntegerList(R, 0,
|
||||
ALARMS_STATUS.MemType,
|
||||
ALARMS_STATUS.Address,
|
||||
((ALARMS_STATUS.Size + ALARMS_DATA.Size) / 4) + 1, // byte / 4
|
||||
((ALARMS_STATUS.Size + ALARMS_DATA.Size) / 2) + 1, // byte / 4
|
||||
ref readValues);
|
||||
|
||||
if (cmsError.IsError())
|
||||
@@ -3130,7 +3131,7 @@ namespace CMS_CORE_Library.Osai
|
||||
|
||||
for (int i = 0; i < bits.Length; i++)
|
||||
{
|
||||
if (i < 32 && i > 62 && bits[i])
|
||||
if ((i < 32 || i > 63) && bits[i])
|
||||
{
|
||||
int bitIndex = i;
|
||||
if (i >= 64) // 32 status bit and 32 lives bit
|
||||
@@ -3164,15 +3165,16 @@ namespace CMS_CORE_Library.Osai
|
||||
cmsError = MEM_RWDWord(R, 0, TOOL_LIFE_UPDATED_DATA.MemType, lifeIndex, ref life);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
// TODO CHECK
|
||||
if(updatedLives.Where(x => x.Key == toolId)?.FirstOrDefault() == null)
|
||||
if (!updatedLives.ContainsKey(toolId))
|
||||
// Insert into the new lives list
|
||||
updatedLives.Add(toolId, life);
|
||||
|
||||
// Setup ack/strobe indexes
|
||||
// if i > (32) + 15 then index = next word
|
||||
strobeByteIndex = i > 69 ? TOOL_LIFE_UPDATED_CMD.Address + 1 : TOOL_LIFE_UPDATED_CMD.Address;
|
||||
ackByteIndex = i > 69 ? TOOL_LIFE_UPDATED_ACK.Address + 1 : TOOL_LIFE_UPDATED_CMD.Address;
|
||||
// if i > (64) + 15 then index = next word
|
||||
strobeByteIndex = i > 79 ? TOOL_LIFE_UPDATED_CMD.Address + 1 : TOOL_LIFE_UPDATED_CMD.Address;
|
||||
ackByteIndex = i > 79 ? TOOL_LIFE_UPDATED_ACK.Address + 1 : TOOL_LIFE_UPDATED_ACK.Address;
|
||||
}
|
||||
|
||||
// Manage ack and strobe
|
||||
@@ -3180,6 +3182,7 @@ namespace CMS_CORE_Library.Osai
|
||||
cmsError = ManageActivePLCAcknowledge(strobeByteIndex, bitIndex, ackByteIndex, bitIndex, MEMORY_TYPE.Osai_MW);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2289,7 +2289,7 @@ namespace CMS_CORE_Library.Siemens
|
||||
{
|
||||
Path = path + "\\" + element.Name,
|
||||
IsDirectory = element.IsDirNode,
|
||||
Name = element.Name,
|
||||
Name = GetStringUntilOrEmpty(element.Name, "."),
|
||||
AbsolutePath = element.LogicalPath
|
||||
};
|
||||
files.Add(file);
|
||||
@@ -2301,7 +2301,7 @@ namespace CMS_CORE_Library.Siemens
|
||||
{
|
||||
Path = path + "\\" + element.Name,
|
||||
IsDirectory = element.IsDirNode,
|
||||
Name = element.Name,
|
||||
Name = element.IsDirNode ? GetStringUntilOrEmpty(element.Name, ".") : element.Name,
|
||||
AbsolutePath = element.LogicalPath
|
||||
};
|
||||
files.Add(file);
|
||||
@@ -4287,7 +4287,7 @@ namespace CMS_CORE_Library.Siemens
|
||||
// Check if the key string has only 1 id
|
||||
if (secondId == 0)
|
||||
{
|
||||
switch (GetUntilOrEmpty(actualString)) // Cut string until [ character
|
||||
switch (GetStringUntilOrEmpty(actualString)) // Cut string until [ character
|
||||
{
|
||||
case "$TC_TP1":
|
||||
{
|
||||
@@ -4460,7 +4460,7 @@ namespace CMS_CORE_Library.Siemens
|
||||
if (lastSecondId != secondId && toolIndex >= 0)
|
||||
edgeIndex = ToolTableData[toolIndex].EdgesData.FindIndex(x => x.Id == secondId);
|
||||
|
||||
switch (GetUntilOrEmpty(actualString))
|
||||
switch (GetStringUntilOrEmpty(actualString))
|
||||
{
|
||||
case "$TC_DP1":
|
||||
{
|
||||
@@ -4614,7 +4614,7 @@ namespace CMS_CORE_Library.Siemens
|
||||
// Find if actual param exist for the tool type
|
||||
List<EdgeConfigModel> toolTypeConfig = toolEdgesConfig.EdgesConfig[tool.ToolType];
|
||||
EdgeConfigModel paramConfig = toolTypeConfig
|
||||
.Where(x => x.Path == (GetUntilOrEmpty(actualString) + "["))
|
||||
.Where(x => x.Path == (GetStringUntilOrEmpty(actualString) + "["))
|
||||
.FirstOrDefault();
|
||||
|
||||
// If Exist
|
||||
@@ -4745,7 +4745,7 @@ namespace CMS_CORE_Library.Siemens
|
||||
{
|
||||
if (secondId == 0)
|
||||
{
|
||||
switch (GetUntilOrEmpty(actualString)) // Cut string until [ character
|
||||
switch (GetStringUntilOrEmpty(actualString)) // Cut string until [ character
|
||||
{
|
||||
case "$TC_TP1":
|
||||
{
|
||||
@@ -4832,7 +4832,7 @@ namespace CMS_CORE_Library.Siemens
|
||||
if (lastSecondId != secondId)
|
||||
edgeIndex = outputTool.EdgesData.FindIndex(x => x.Id == secondId);
|
||||
|
||||
switch (GetUntilOrEmpty(actualString))
|
||||
switch (GetStringUntilOrEmpty(actualString))
|
||||
{
|
||||
case "$TC_DP1":
|
||||
{
|
||||
@@ -4977,7 +4977,7 @@ namespace CMS_CORE_Library.Siemens
|
||||
// Find if actual param exist for the tool type
|
||||
List<EdgeConfigModel> toolTypeConfig = toolEdgesConfig.EdgesConfig[outputTool.ToolType];
|
||||
EdgeConfigModel paramConfig = toolTypeConfig
|
||||
.Where(x => x.Path == (GetUntilOrEmpty(actualString) + "["))
|
||||
.Where(x => x.Path == (GetStringUntilOrEmpty(actualString) + "["))
|
||||
.FirstOrDefault();
|
||||
|
||||
// If Exist
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace CMS_CORE_Library.Utils
|
||||
}
|
||||
|
||||
// Get a substring from the beginning until the specified character -> defautl "["
|
||||
internal static string GetUntilOrEmpty(string text, string stopAt = "[")
|
||||
internal static string GetStringUntilOrEmpty(string text, string stopAt = "[")
|
||||
{
|
||||
// Get string unti
|
||||
if (!String.IsNullOrWhiteSpace(text))
|
||||
|
||||
Reference in New Issue
Block a user