diff --git a/CMS_CORE_Application/Form1.cs b/CMS_CORE_Application/Form1.cs index 2440768..6a26e35 100644 --- a/CMS_CORE_Application/Form1.cs +++ b/CMS_CORE_Application/Form1.cs @@ -74,6 +74,7 @@ namespace CMS_CORE_Application CmsError cmsError = N.NC_Connect(); cmsError = N.NC_RModelName(ref ModelName); + MessageBox.Show(cmsError.localizationKey); cmsError = N.NC_WLanguage(new System.Globalization.CultureInfo("it")); bool error = false; string serial = ""; @@ -101,20 +102,15 @@ namespace CMS_CORE_Application cmsError = N.NC_RSerialNumber(ref serial); if (cmsError.IsError()){ error = true; SetError(Lines, cmsError); } + Dictionary dictionary = new Dictionary(); + cmsError = N.NC_GetTranslatedPlcMessages("it", ref dictionary); List axes = new List(); ////////////////////////////////////////// TEST Stopwatch st = new Stopwatch(); sw.Restart(); - ActiveProgramDataModel active = new ActiveProgramDataModel(); - int a = 0; - // N.FILES_WDeactivateProgram(1); - if(a == 0) - cmsError = N.FILES_WSetActiveProgram(1, "C:\\PartPrg\\nuovo.mpf", ref active); - a++; - MountedToolModel mounted = new MountedToolModel(); - N.TOOLS_WLoadToolInMagazine(1, new NewToolInMagazineModel() { PositionId = 2, ToolId = 3 }, ref mounted); + cmsError = N.PLC_WOperatorInputResponse(1, 230.0); Console.WriteLine("TIME " + sw.ElapsedMilliseconds); sw.Stop(); diff --git a/CMS_CORE_Library/Demo/Nc_Demo.cs b/CMS_CORE_Library/Demo/Nc_Demo.cs index 8e16884..8085be7 100644 --- a/CMS_CORE_Library/Demo/Nc_Demo.cs +++ b/CMS_CORE_Library/Demo/Nc_Demo.cs @@ -826,7 +826,7 @@ namespace CMS_CORE_Library.Demo { value.Add(new M155InputIsNeededModel() { - Process = i, + Process = i + 1, IsNeeded = true, Buttons = new Dictionary() { diff --git a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs index ca26525..1cab62b 100644 --- a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs +++ b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs @@ -277,10 +277,10 @@ namespace CMS_CORE_Library.Fanuc // Get the processes-count configurated public override CmsError NC_RProcessesNum(ref ushort ProcNumber) { - //Read static data - CmsError cmsError = ReadStaticNCData(); - if (cmsError.IsError()) - return cmsError; + ////Read static data + //CmsError cmsError = ReadStaticNCData(); + //if (cmsError.IsError()) + // return cmsError; ProcNumber = (ushort)Cnc_NumPath; @@ -1456,9 +1456,7 @@ namespace CMS_CORE_Library.Fanuc Axes.Add(axis.Key, axis.Value + ToGo[axis.Key]); } } - else - return CmsError.InternalError("Impossible to get programmed position"); - + return NO_ERROR; } @@ -1546,7 +1544,7 @@ namespace CMS_CORE_Library.Fanuc // Get from PLC which axis can be selected List ids = new List(); - CmsError cmsError = MEM_RWByteList(R, 0, AXES_BUTTON_VISIBLE.MemType, AXES_BUTTON_VISIBLE.Address, AXES_BUTTON_VISIBLE.SubAddress, 0, AXES_BUTTON_VISIBLE.Size, ref ids); + CmsError cmsError = MEM_RWByteList(R, 0, AXES_BUTTON_VISIBLE.MemType, AXES_BUTTON_VISIBLE.Address, 0, AXES_BUTTON_VISIBLE.Size, ref ids); if (cmsError.IsError()) return cmsError; @@ -2264,7 +2262,7 @@ namespace CMS_CORE_Library.Fanuc { AbsolutePath = path + currDirOutData.d_f, IsDirectory = true, - Name = Path.GetDirectoryName(currDirOutData.d_f), + Name = currDirOutData.d_f, Path = path }); } @@ -2293,15 +2291,15 @@ namespace CMS_CORE_Library.Fanuc // Add to list read data files.Add(new PreviewFileModel() { - AbsolutePath = path + fileData.d_f, + AbsolutePath = (path + fileData.d_f).Replace('/', '\\'), IsDirectory = false, - Name = fileData.d_f, - Path = path + Name = fileData.d_f, + Path = path.Replace('/', '\\') }); } } } - catch (Exception ex) + catch (Exception ex) { return ManageException(ex); } @@ -2847,7 +2845,7 @@ namespace CMS_CORE_Library.Fanuc config.Add(new NcMagazineConfigModel() { Id = (byte)(i + 1), - MaxPositions = readShorts[i + 5], + MaxPositions = readShorts[i + 10], Type = (NC_MAGAZINE_TYPE)types[i] }); } @@ -3798,7 +3796,6 @@ namespace CMS_CORE_Library.Fanuc short nReturn1, nReturn2; Focas1.ODBSYS node = new Focas1.ODBSYS(); - Focas1.ODBSYS tmpNode = new Focas1.ODBSYS(); Focas1.ODBSYSEX nodeex = new Focas1.ODBSYSEX(); ulong SerialNumber = 0; @@ -3810,32 +3807,29 @@ namespace CMS_CORE_Library.Fanuc if (cmsError.IsError()) return cmsError; - //Execute the method - nReturn1 = Focas1.cnc_sysinfo(nLibHandle[0], tmpNode); - - node = tmpNode; + // Execute the method + nReturn1 = Focas1.cnc_sysinfo(nLibHandle[0], node); + nReturn2 = Focas1.cnc_rdcncid(nLibHandle[0], out SerialNumber); - //Throw Exception if there's an error + // Throw Exception if there's an error if (nReturn1 != 0) { - MessageBox.Show("return 1 " + nReturn1); - return GetNcError(nReturn1); } else if (nReturn2 != 0 && nReturn2 != 1) { - MessageBox.Show("return 2 " + nReturn2); - return GetNcError(nReturn2); } else { + Cnc_name = "NOME_CN"; + Cnc_SftVersion = "VERSIONE_SW"; //Setup the name - Cnc_name = GetName(node.cnc_type, node.mt_type); + // Cnc_name = GetName(node.cnc_type, node.mt_type); //Setup the Software version - Cnc_SftVersion = new string(node.version); + //Cnc_SftVersion = new string(node.version); //Setup the Number Series Cnc_SeriesNum = SerialNumber.ToString(); @@ -3890,7 +3884,7 @@ namespace CMS_CORE_Library.Fanuc private string GetName(char[] Cnc_Type, char[] Mt_Type) { string name = "Fanuc "; - switch (new string(Cnc_Type)) + switch (string.Join("", Cnc_Type)) { case "15": name += "15 Series"; break; case "16": name += "16 Series"; break; @@ -3902,7 +3896,7 @@ namespace CMS_CORE_Library.Fanuc case "35": name += "35i Series"; break; case "0": name += "0i Series"; break; } - name += " " + new string(Mt_Type); + name += " " + string.Join("", Mt_Type); return name; } @@ -4178,7 +4172,7 @@ namespace CMS_CORE_Library.Fanuc internal static MEMORY_CELL TOOL_LIFE_UPDATED_DATA = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, STARTING_ADDRESS + 4073, 80); internal static MEMORY_CELL MAGAZINE_TYPES = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, STARTING_ADDRESS + 4153, 0); - internal static MEMORY_CELL MAGAZINE_POSITIONS_NUMBER = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, STARTING_ADDRESS + 1573, 0); + internal static MEMORY_CELL MAGAZINE_POSITIONS_NUMBER = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, STARTING_ADDRESS + 4173, 0); internal static MEMORY_CELL MAGAZINES_ENABLED_CMD = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, STARTING_ADDRESS + 4213, 4); internal static MEMORY_CELL MAGAZINES_TOOLING_CMD = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, STARTING_ADDRESS + 4217, 4); @@ -4187,6 +4181,6 @@ namespace CMS_CORE_Library.Fanuc internal static MEMORY_CELL TOOL_TABLE_INDEX = new MEMORY_CELL(MEMORY_TYPE.Fanuc_D, 10000, 6900); internal static MEMORY_CELL FAMILY_TABLE_INDEX = new MEMORY_CELL(MEMORY_TYPE.Fanuc_D, 17000, 7500); internal static MEMORY_CELL SHANK_TABLE_INDEX = new MEMORY_CELL(MEMORY_TYPE.Fanuc_D, 24600, 3300); - internal static MEMORY_CELL MAG_POS_TABLE_INDEX = new MEMORY_CELL(MEMORY_TYPE.Fanuc_D, 28000, 900); + internal static MEMORY_CELL MAG_POS_TABLE_INDEX = new MEMORY_CELL(MEMORY_TYPE.Fanuc_D, 28000, 1200); } } \ No newline at end of file diff --git a/CMS_CORE_Library/Osai/Nc_Osai.cs b/CMS_CORE_Library/Osai/Nc_Osai.cs index e404131..b61e197 100644 --- a/CMS_CORE_Library/Osai/Nc_Osai.cs +++ b/CMS_CORE_Library/Osai/Nc_Osai.cs @@ -42,17 +42,17 @@ namespace CMS_CORE_Library.Osai //Path Variable private const string PLC_MESSAGE_PATH = @"C:\CMS\OSAI\"; private readonly string WINNBI_PATH = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + @"\OSAI\WinNBI\"; - private const string TOOL_MANAGER_DIRECTORY_PATH = @"STEP\"; + private const string TOOL_MANAGER_DIRECTORY_PATH = @"ACTIVE\"; private const string NC_PROGRAM_PATH = @"CAMBIO\"; private const string NC_PROGRAM_UPLOAD_PATH = @"CAMBIO\UPLOADED_PP\"; - // private const string TOOL_MANAGER_DIRECTORY_PATH = @"test\OEM\CMS\SYS\STEP\"; + //private const string TOOL_MANAGER_DIRECTORY_PATH = @"active\OEM\CMS\SYS\ACTIVE\"; private static List EXT_PP = new List() { "", "TXT", "CNC", "INI" }; private static List EXT_IMG = new List() { "PNG", "JPG", "JPEG" }; private const uint MAX_ROWS_FILE_PREVIEW = 10; // massimo 10 righe - private const string TOOL_MANAGER_BACKUP_DIRECTORY_PATH = @"C:\CMS\STEP\TMP\"; + 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"; @@ -123,12 +123,12 @@ namespace CMS_CORE_Library.Osai else Connected = false; - //Try to retireve the NC-Status - nReturn = OpenNC.LogFSFindFirst(TOOL_MANAGER_DIRECTORY_PATH, out FILEFINDDATA findData, out uint finder, out errorClass, out errorNum); + //// Check if tool manager folder exist + //nReturn = OpenNC.LogFSFindFirst(TOOL_MANAGER_DIRECTORY_PATH, out FILEFINDDATA findData, out uint finder, out errorClass, out errorNum); - //If there's an error - if (errorClass != 0 || errorNum != 0 || nReturn == 0) - return GetNCError(errorClass, errorNum); + ////If there's an error + //if (errorClass != 0 || errorNum != 0 || nReturn == 0) + // return GetNCError(errorClass, errorNum); } catch (Exception ex) { @@ -472,7 +472,7 @@ namespace CMS_CORE_Library.Osai if (statusBits[i]) { // Calculate matching alarm byte info address - int dataByteAddress = (i * 8 + ALARMS_NUMBER ) + 16; + int dataByteAddress = (i * 16 + ALARMS_NUMBER ) + 16; var processList = new List(); @@ -2694,22 +2694,23 @@ namespace CMS_CORE_Library.Osai return cmsError; // Read data 10 status, 10 magazine position numbers List readShorts = new List(); - cmsError = MEM_RWWordList(R, 0, MAGAZINE_TYPES.MemType, MAGAZINE_TYPES.Address, 20, ref readShorts); + cmsError = MEM_RWWordList(R, 0, MAGAZINE_TYPES.MemType, MAGAZINE_TYPES.Address, 32, ref readShorts); if (cmsError.IsError()) return cmsError; List types = new List(); + // Convert into list o fbytes types = readShorts.SelectMany(BitConverter.GetBytes).ToList(); config = new List(); for (int i = 0; i < 10; i++) { - // Check if there are positions - if (types[i + 20] > 0) + // Check if there are positions (skip the 5 status word) + if (readShorts[i + 12] > 0) config.Add(new NcMagazineConfigModel() { Id = (byte)(i + 1), - MaxPositions = types[i + 20], + MaxPositions = readShorts[i + 12], Type = (NC_MAGAZINE_TYPE)types[i] }); } @@ -3163,9 +3164,10 @@ namespace CMS_CORE_Library.Osai cmsError = MEM_RWDWord(R, 0, TOOL_LIFE_UPDATED_DATA.MemType, lifeIndex, ref life); if (cmsError.IsError()) return cmsError; - - // Insert into the new lives list - updatedLives.Add(toolId, life); + // TODO CHECK + if(updatedLives.Where(x => x.Key == toolId)?.FirstOrDefault() == null) + // Insert into the new lives list + updatedLives.Add(toolId, life); // Setup ack/strobe indexes // if i > (32) + 15 then index = next word @@ -3945,8 +3947,8 @@ namespace CMS_CORE_Library.Osai internal static MEMORY_CELL USER_SOFTKEYS_VALUE = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4042, 0, 16); internal static MEMORY_CELL USER_SOFTKEYS_CLICKABLE = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4053, 0, 16); - internal static MEMORY_CELL USER_SOFT_KEYS_ACK = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 12818, 16); - internal static MEMORY_CELL USER_SOFT_KEYS_CLICKED = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 12825, 16); + internal static MEMORY_CELL USER_SOFT_KEYS_ACK = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4062, 16); + internal static MEMORY_CELL USER_SOFT_KEYS_CLICKED = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4072, 16); internal static MEMORY_CELL HEADS_DATA = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4101, 240); diff --git a/CMS_CORE_Library/Siemens/Nc_Siemens.cs b/CMS_CORE_Library/Siemens/Nc_Siemens.cs index 4f1e238..a6ef024 100644 --- a/CMS_CORE_Library/Siemens/Nc_Siemens.cs +++ b/CMS_CORE_Library/Siemens/Nc_Siemens.cs @@ -1095,13 +1095,13 @@ namespace CMS_CORE_Library.Siemens }; dataSvc.Write(item); + + return PLC_WStrobe(M155_INPUT_ACK, M155_INPUT_STROBE,(uint)process); } catch (Exception ex) { return ManageException(ex); } - - return NO_ERROR; } public override CmsError PLC_RMTConnectData(ref List data) @@ -1226,10 +1226,10 @@ namespace CMS_CORE_Library.Siemens bool readValue = false; bool writeValue = true; - SetupAckStrobeAddresses(ackCell.SubAddress, strobeCell.SubAddress, id, out int ackWord, out int strobeWord, out int alarmBitId); + SetupAckStrobeAddresses(ackCell.SubAddress, strobeCell.SubAddress, id, out int ackByte, out int strobeByte, out int alarmBitId); // Check Strobe - cmsError = MEM_RWBoolean(R, 0, strobeCell.MemType, strobeCell.Address, strobeWord, alarmBitId, ref readValue); + cmsError = MEM_RWBoolean(R, 0, strobeCell.MemType, strobeCell.Address, strobeByte, alarmBitId, ref readValue); if (cmsError.IsError()) return cmsError; @@ -1238,7 +1238,7 @@ namespace CMS_CORE_Library.Siemens return NO_ERROR; // Check ACK - cmsError = MEM_RWBoolean(R, 0, ackCell.MemType, ackCell.Address, ackWord, alarmBitId, ref readValue); + cmsError = MEM_RWBoolean(R, 0, ackCell.MemType, ackCell.Address, ackByte, alarmBitId, ref readValue); if (cmsError.IsError()) return cmsError; @@ -1247,22 +1247,22 @@ namespace CMS_CORE_Library.Siemens return NO_ERROR; // Write strobe into memory - cmsError = MEM_RWBoolean(W, 0, strobeCell.MemType, strobeCell.Address, strobeWord, alarmBitId, ref writeValue); + cmsError = MEM_RWBoolean(W, 0, strobeCell.MemType, strobeCell.Address, strobeByte, alarmBitId, ref writeValue); if (cmsError.IsError()) return cmsError; // Reset wait ack = 1 and reset the strobe - cmsError = ResetStrobe(alarmBitId, strobeWord, ackWord, ackCell.MemType); + cmsError = ResetStrobe(alarmBitId, strobeByte, ackByte, ackCell.MemType); if (cmsError.IsError()) return cmsError; return NO_ERROR; } - private void SetupAckStrobeAddresses(int ackAddress, int strobeAddress, uint id, out int ackWord, out int strobeWord, out int bit) + private void SetupAckStrobeAddresses(int ackAddress, int strobeAddress, uint id, out int ackByte, out int strobeByte, out int bit) { - ackWord = ackAddress + (((int)id - 1) / 8); - strobeWord = strobeAddress + (((int)id - 1) / 8); + ackByte = ackAddress + (((int)id - 1) / 8); + strobeByte = strobeAddress + (((int)id - 1) / 8); bit = (((int)id - 1) % 8); } @@ -5607,6 +5607,9 @@ namespace CMS_CORE_Library.Siemens internal static MEMORY_CELL COUNTERS_STROBE = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 3010, 2); internal static MEMORY_CELL M155_INPUT_NEEDED = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 3014, 1); + internal static MEMORY_CELL M155_INPUT_ACK = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 3015, 1); + internal static MEMORY_CELL M155_INPUT_STROBE = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 3016, 1); + internal static MEMORY_CELL MTCONNECT_DATA_NEEDED = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 3042, 1); internal static MEMORY_CELL AXES_BUTTON_VISIBLE = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 3044, 16); diff --git a/CMS_CORE_Library/ToolConfigurations.cs b/CMS_CORE_Library/ToolConfigurations.cs index c1860b6..a0533a6 100644 --- a/CMS_CORE_Library/ToolConfigurations.cs +++ b/CMS_CORE_Library/ToolConfigurations.cs @@ -240,8 +240,8 @@ namespace CMS_CORE_Library new FieldsConfiguration{ Name = "id", Type = "int", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = 0}, new FieldsConfiguration{ Name = "name", Type = "string", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = 0}, new FieldsConfiguration{ Name = "toolType", Type = "int", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = byte.MaxValue}, - new FieldsConfiguration{ Name = "leftSize", Type = "int", SelectValues = null, Category = "magazine", ReadOnly = false, MinValue = 0, MaxValue = byte.MaxValue}, - new FieldsConfiguration{ Name = "rightSize", Type = "int", SelectValues = null, Category = "magazine", ReadOnly = false, MinValue = 0, MaxValue = byte.MaxValue}, + new FieldsConfiguration{ Name = "leftSize", Type = "int", SelectValues = null, Category = "magazine", ReadOnly = false, MinValue = 1, MaxValue = byte.MaxValue}, + new FieldsConfiguration{ Name = "rightSize", Type = "int", SelectValues = null, Category = "magazine", ReadOnly = false, MinValue = 1, MaxValue = byte.MaxValue}, new FieldsConfiguration{ Name = "tcpTable", Type = "int", SelectValues = null, Category = "tcp", ReadOnly = false, MinValue = 0, MaxValue = byte.MaxValue}, new FieldsConfiguration{ Name = "gamma", Type = "int", SelectValues = null, Category = "gamma", ReadOnly = false, MinValue = 0, MaxValue = byte.MaxValue}, new FieldsConfiguration{ Name = "rotationType", Type = "select", SelectValues = cmsRotationTypeList, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = byte.MaxValue},