diff --git a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs index 21a0840..b2ea43f 100644 --- a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs +++ b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs @@ -169,14 +169,15 @@ namespace CMS_CORE_Library.Fanuc try { CultureInfo cultureInfo = CultureInfo.CreateSpecificCulture(language); - string langName = ""; + // Use ISO-639-2 + string threeLetterIso = ""; if (cultureInfo.IsNeutralCulture) - langName = cultureInfo.EnglishName; + threeLetterIso = cultureInfo.ThreeLetterISOLanguageName; else - langName = cultureInfo.Parent.EnglishName; + threeLetterIso = cultureInfo.Parent.ThreeLetterISOLanguageName; //Setup the Path - filePath = PLC_MESSAGE_PATH + @"Messaggi_" + langName + @".txt"; + filePath = PLC_MESSAGE_PATH + @"Messaggi_" + threeLetterIso + @".txt"; if (!File.Exists(filePath)) return FILE_NOT_FOUND_ERROR; @@ -226,11 +227,15 @@ namespace CMS_CORE_Library.Fanuc public override CmsError NC_WLanguage(CultureInfo Language) { // set but 7 to TRUE - byte langToWrite = (byte)(ConvertToNCLanguage(Language) | 128); + byte langToWrite = (byte)(ConvertToNCLanguage(Language, out bool isSpecial) | 128); // write the byte CmsError cmsError = MEM_RWByte(W, 0, PARAM_LING_FANUC_W.MemType, PARAM_LING_FANUC_W.Address, 0, ref langToWrite); + if (cmsError.IsError()) + return cmsError; + // Write if the selected language is special + cmsError = MEM_RWBoolean(W, 0, SPECIAL_LANGUAGE_BIT.MemType, SPECIAL_LANGUAGE_BIT.Address, SPECIAL_LANGUAGE_BIT.SubAddress, 0, ref isSpecial); if (cmsError.IsError()) return cmsError; @@ -1651,6 +1656,11 @@ namespace CMS_CORE_Library.Fanuc public override CmsError PROC_RSelectedProcessData(int processId, ref SelectedProcessData processData) { + //Check if the NC is Connected + CmsError cmsError = CheckConnection(); + if (cmsError.IsError()) + return cmsError; + if (processId <= 0) return PROC_NOT_FOUND_ERROR; @@ -3347,10 +3357,10 @@ namespace CMS_CORE_Library.Fanuc Action = (MAGAZINE_ACTIONS)actionId, Tool = tool, SecondTool = secondTool, - OriginMagazine = wordList[2], - OriginPosition = wordList[3], - DestinationMagazine = wordList[4], - DestinationPosition = wordList[5] + DestinationMagazine = wordList[2], + DestinationPosition = wordList[3], + OriginMagazine = wordList[4], + OriginPosition = wordList[5], }; } @@ -3754,6 +3764,23 @@ namespace CMS_CORE_Library.Fanuc // Test FromMemoryToModels(readInt, out families); + readInt = new List(); + cmsError = MEM_RWIntegerList(R, 0, TOOL_TABLE_INDEX.MemType, TOOL_TABLE_INDEX.Address, TOOL_TABLE_INDEX.Size / 4, ref readInt); + if (cmsError.IsError()) + return cmsError; + + // Test + FromMemoryToModels(readInt, out tools); + + + readInt = new List(); + cmsError = MEM_RWIntegerList(R, 0, SHANK_TABLE_INDEX.MemType, SHANK_TABLE_INDEX.Address, SHANK_TABLE_INDEX.Size / 4, ref readInt); + if (cmsError.IsError()) + return cmsError; + + // Test + FromMemoryToModels(readInt, out shanks); + return NO_ERROR; } @@ -3817,7 +3844,7 @@ namespace CMS_CORE_Library.Fanuc if (!skipAssignment) { // Check if property is unsigned or not - if (properties[propertyIndex].GetType() == typeof(ushort)) + if (properties[propertyIndex].PropertyType == typeof(ushort)) properties[propertyIndex].SetValue(models[objIndex], (ushort)u); else properties[propertyIndex].SetValue(models[objIndex], u); @@ -3832,7 +3859,7 @@ namespace CMS_CORE_Library.Fanuc int i = BitConverter.ToInt32(new byte[4] { byteValues[memoryIndex], byteValues[memoryIndex + 1], byteValues[memoryIndex + 2], byteValues[memoryIndex + 3], }, 0); // Check if property is unsigned or not - if (properties[propertyIndex].GetType() == typeof(uint)) + if (properties[propertyIndex].PropertyType == typeof(uint)) properties[propertyIndex].SetValue(models[objIndex], (uint)i); else properties[propertyIndex].SetValue(models[objIndex], i); @@ -4410,8 +4437,9 @@ namespace CMS_CORE_Library.Fanuc } // Convert to NC Language - private byte ConvertToNCLanguage(CultureInfo language) + private byte ConvertToNCLanguage(CultureInfo language, out bool isSpecial) { + isSpecial = false; switch (language.Name) { case "en": return 0; @@ -4436,7 +4464,11 @@ namespace CMS_CORE_Library.Fanuc case "ro": return 19; case "sk": return 20; case "fi": return 21; - default: return 0; + default: + { + isSpecial = true; + return 0; + } } } @@ -4804,6 +4836,10 @@ namespace CMS_CORE_Library.Fanuc internal const int STARTING_ADDRESS = 20000; internal static MEMORY_CELL NC_WATCHDOG = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, STARTING_ADDRESS, 1); + + // Special language parameter + internal static MEMORY_CELL SPECIAL_LANGUAGE_BIT = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R,STARTING_ADDRESS + 2, 1, 1); + internal static MEMORY_CELL ACTIVE_WATCHDOG = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, STARTING_ADDRESS + 2, 1); internal static MEMORY_CELL FUNCTION_ACCESS = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, STARTING_ADDRESS + 5, 8); diff --git a/CMS_CORE_Library/Models/CmsError.cs b/CMS_CORE_Library/Models/CmsError.cs index daa678d..b7974f8 100644 --- a/CMS_CORE_Library/Models/CmsError.cs +++ b/CMS_CORE_Library/Models/CmsError.cs @@ -59,6 +59,7 @@ HMI_NOT_RESPONDING = 24, PROGRAM_IS_SELECTED = 25, SELECTED_PROCESS = 26, - OSAI_TT_FOLDER_NOT_FOUND = 27 + OSAI_TT_FOLDER_NOT_FOUND = 27, + OPTION_NOT_CONSISTENT = 28 } } \ No newline at end of file diff --git a/CMS_CORE_Library/Models/DataStructures.cs b/CMS_CORE_Library/Models/DataStructures.cs index deb2d9e..11f32ad 100644 --- a/CMS_CORE_Library/Models/DataStructures.cs +++ b/CMS_CORE_Library/Models/DataStructures.cs @@ -194,6 +194,7 @@ namespace CMS_CORE_Library.Models public static CmsError PROGRAM_IS_SELECTED_ERROR = new CmsError(CMS_ERROR_CODES.PROGRAM_IS_SELECTED, "error_program_is_selected"); public static CmsError SELECTED_PROCESS_ERROR = new CmsError(CMS_ERROR_CODES.SELECTED_PROCESS, "error_selected_process_not_found"); public static CmsError OSAI_TT_FOLDER_NOT_FOUND_ERROR = new CmsError(CMS_ERROR_CODES.OSAI_TT_FOLDER_NOT_FOUND, "osai_tt_folder_not_found_error"); + public static CmsError OPTION_NOT_CONSISTENT_ERROR = new CmsError(CMS_ERROR_CODES.OPTION_NOT_CONSISTENT, "error_option_not_consistent"); #endregion Cms Errors Codes