From ef5a0c1c3a1de015d580824b6d8fd01f620c4822 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 12 May 2020 11:32:41 +0200 Subject: [PATCH 01/12] Aggiunto test lettura REAL --- SiemensS7/Siemens-S7-Test/TestMainForm.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/SiemensS7/Siemens-S7-Test/TestMainForm.cs b/SiemensS7/Siemens-S7-Test/TestMainForm.cs index e4000d2..f34fda3 100644 --- a/SiemensS7/Siemens-S7-Test/TestMainForm.cs +++ b/SiemensS7/Siemens-S7-Test/TestMainForm.cs @@ -589,6 +589,7 @@ namespace Siemens_S7_Test string byteVal = ""; ushort shortVal = 0; uint intVal = 0; + double realVal = 0; string byteValA = ""; string byteValB = ""; string byteValC = ""; @@ -637,6 +638,17 @@ namespace Siemens_S7_Test contenuto += $"---------{Environment.NewLine}"; } break; + case "real": + for (int i = 0; i < memByteRead.Length / 4; i++) + { + byteValA = Convert.ToString(memByteRead[i * 4], 2).PadLeft(8, '0'); + byteValB = Convert.ToString(memByteRead[i * 4 + 1], 2).PadLeft(8, '0'); + byteValC = Convert.ToString(memByteRead[i * 4 + 2], 2).PadLeft(8, '0'); + byteValD = Convert.ToString(memByteRead[i * 4 + 3], 2).PadLeft(8, '0'); + realVal = S7.Net.Types.Double.FromByteArray(memByteRead.Skip(4 * i).Take(4).ToArray()); + contenuto += string.Format("R{0:000}: {1} | {2}-{3}-{4}-{5}{6}", i, realVal, byteValA, byteValB, byteValC, byteValD, Environment.NewLine); + } + break; case "byte": default: for (int i = 0; i < memByteRead.Length; i++) From 8aa477b8835342eed2c493a5118433a8a2b6637f Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 12 May 2020 12:10:43 +0200 Subject: [PATCH 02/12] Start modifying demo app + exclusion old synomerik operate --- CMS_CORE_Application/Form1.Designer.cs | 55 +++++++++++++------------- CMS_CORE_Application/Form1.cs | 34 ++++++++++++---- CMS_CORE_Library/S7Net/Nc_S7Net.cs | 17 +++++--- 3 files changed, 66 insertions(+), 40 deletions(-) diff --git a/CMS_CORE_Application/Form1.Designer.cs b/CMS_CORE_Application/Form1.Designer.cs index 3329928..0edbcb7 100644 --- a/CMS_CORE_Application/Form1.Designer.cs +++ b/CMS_CORE_Application/Form1.Designer.cs @@ -69,14 +69,14 @@ this.TXTPPName = new System.Windows.Forms.TextBox(); this.TXTPPLines = new System.Windows.Forms.TextBox(); this.groupBox5 = new System.Windows.Forms.GroupBox(); + this.label12 = new System.Windows.Forms.Label(); + this.labelTest1TXT = new System.Windows.Forms.TextBox(); this.labelTest = new System.Windows.Forms.Label(); this.labelTest2TXT = new System.Windows.Forms.TextBox(); this.TXTNow = new System.Windows.Forms.TextBox(); this.label7 = new System.Windows.Forms.Label(); this.label10 = new System.Windows.Forms.Label(); this.Error = new System.Windows.Forms.TextBox(); - this.label12 = new System.Windows.Forms.Label(); - this.labelTest1TXT = new System.Windows.Forms.TextBox(); this.panel1.SuspendLayout(); this.tableLayoutPanel3.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); @@ -207,7 +207,8 @@ "Demo", "Fanuc", "Siemens", - "Osai"}); + "Osai", + "S7Net"}); this.NcCombo.Location = new System.Drawing.Point(484, 3); this.NcCombo.Name = "NcCombo"; this.NcCombo.Size = new System.Drawing.Size(150, 21); @@ -354,7 +355,7 @@ this.tableLayoutPanel1.ColumnCount = 3; this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.76253F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 49.23747F)); - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 296F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 297F)); this.tableLayoutPanel1.Controls.Add(this.groupBox2, 1, 0); this.tableLayoutPanel1.Controls.Add(this.groupBox1, 0, 0); this.tableLayoutPanel1.Controls.Add(this.groupBox4, 2, 0); @@ -375,7 +376,7 @@ this.groupBox2.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.groupBox2.Location = new System.Drawing.Point(158, 3); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(145, 265); + this.groupBox2.Size = new System.Drawing.Size(144, 265); this.groupBox2.TabIndex = 28; this.groupBox2.TabStop = false; this.groupBox2.Text = "Plc"; @@ -389,7 +390,7 @@ this.TXTMsg.Multiline = true; this.TXTMsg.Name = "TXTMsg"; this.TXTMsg.ReadOnly = true; - this.TXTMsg.Size = new System.Drawing.Size(134, 238); + this.TXTMsg.Size = new System.Drawing.Size(133, 238); this.TXTMsg.TabIndex = 18; // // groupBox1 @@ -424,9 +425,9 @@ | System.Windows.Forms.AnchorStyles.Right))); this.groupBox4.Controls.Add(this.tabControl1); this.groupBox4.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.groupBox4.Location = new System.Drawing.Point(309, 3); + this.groupBox4.Location = new System.Drawing.Point(308, 3); this.groupBox4.Name = "groupBox4"; - this.groupBox4.Size = new System.Drawing.Size(291, 265); + this.groupBox4.Size = new System.Drawing.Size(292, 265); this.groupBox4.TabIndex = 29; this.groupBox4.TabStop = false; this.groupBox4.Text = "Path"; @@ -440,7 +441,7 @@ this.tabControl1.Location = new System.Drawing.Point(6, 21); this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; - this.tabControl1.Size = new System.Drawing.Size(278, 238); + this.tabControl1.Size = new System.Drawing.Size(279, 238); this.tabControl1.TabIndex = 0; // // tabPage1 @@ -449,7 +450,7 @@ this.tabPage1.Location = new System.Drawing.Point(4, 22); this.tabPage1.Name = "tabPage1"; this.tabPage1.Padding = new System.Windows.Forms.Padding(3); - this.tabPage1.Size = new System.Drawing.Size(270, 212); + this.tabPage1.Size = new System.Drawing.Size(271, 212); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "Path 1"; this.tabPage1.UseVisualStyleBackColor = true; @@ -463,7 +464,7 @@ this.TXTAlm.Multiline = true; this.TXTAlm.Name = "TXTAlm"; this.TXTAlm.ReadOnly = true; - this.TXTAlm.Size = new System.Drawing.Size(258, 203); + this.TXTAlm.Size = new System.Drawing.Size(259, 203); this.TXTAlm.TabIndex = 18; // // groupBox3 @@ -590,6 +591,22 @@ this.groupBox5.TabStop = false; this.groupBox5.Text = "Nc Info"; // + // label12 + // + this.label12.AutoSize = true; + this.label12.Location = new System.Drawing.Point(95, 73); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(66, 13); + this.label12.TabIndex = 32; + this.label12.Text = "Label Test 1"; + // + // labelTest1TXT + // + this.labelTest1TXT.Location = new System.Drawing.Point(164, 70); + this.labelTest1TXT.Name = "labelTest1TXT"; + this.labelTest1TXT.Size = new System.Drawing.Size(217, 20); + this.labelTest1TXT.TabIndex = 31; + // // labelTest // this.labelTest.AutoSize = true; @@ -643,22 +660,6 @@ this.Error.Size = new System.Drawing.Size(462, 20); this.Error.TabIndex = 27; // - // label12 - // - this.label12.AutoSize = true; - this.label12.Location = new System.Drawing.Point(95, 73); - this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(66, 13); - this.label12.TabIndex = 32; - this.label12.Text = "Label Test 1"; - // - // labelTest1TXT - // - this.labelTest1TXT.Location = new System.Drawing.Point(164, 70); - this.labelTest1TXT.Name = "labelTest1TXT"; - this.labelTest1TXT.Size = new System.Drawing.Size(217, 20); - this.labelTest1TXT.TabIndex = 31; - // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); diff --git a/CMS_CORE_Application/Form1.cs b/CMS_CORE_Application/Form1.cs index 858e9cf..3927645 100644 --- a/CMS_CORE_Application/Form1.cs +++ b/CMS_CORE_Application/Form1.cs @@ -3,6 +3,7 @@ using CMS_CORE_Library.Demo; using CMS_CORE_Library.Fanuc; using CMS_CORE_Library.Models; using CMS_CORE_Library.Osai; +using CMS_CORE_Library.S7Net; using CMS_CORE_Library.Siemens; using System; using System.Collections.Generic; @@ -117,16 +118,24 @@ namespace CMS_CORE_Application OffsetModel off = new OffsetModel(); cmsError = N.TOOLS_ROffset(1, ref off); - try + // in caso di errore (es S7Net) escludo + if (cmsError.IsError()) { - off.CustomDouble[3] = 88.22; - - off.CustomInt[1] = 15; - cmsError = N.TOOLS_WOffset(1, ref off); + error = true; SetError(Lines, cmsError); } - catch (Exception ex) + else { - labelTest1TXT.Text = ex.Message; + try + { + off.CustomDouble[3] = 88.22; + + off.CustomInt[1] = 15; + cmsError = N.TOOLS_WOffset(1, ref off); + } + catch (Exception ex) + { + labelTest1TXT.Text = ex.Message; + } } MovementBetweenMagazinesModel mov = new MovementBetweenMagazinesModel(); @@ -138,7 +147,7 @@ namespace CMS_CORE_Application N.PROC_RSelectedProcessData(1, ref a); sw.Stop(); - Console.WriteLine("TEMPO PER FUNZIONE " + sw.ElapsedMilliseconds); + Console.WriteLine("TEMPO PER FUNZIONE " + sw.ElapsedMilliseconds); ////////////////////////////////////////////////////////////// END TEST if (!this.IsDisposed && this.InvokeRequired) @@ -205,6 +214,8 @@ namespace CMS_CORE_Application return new Nc_Osai(NCIp, NCPort, 50000); if (NCType == "Fanuc") return new Nc_Fanuc(NCIp, NCPort, 2000); + if (NCType == "S7Net") + return new Nc_S7Net(NCIp, NCPort, 500); return null; } @@ -240,6 +251,13 @@ namespace CMS_CORE_Application TXTip.Text = "localhost"; TXTport.Text = "8080"; } + else if (NcCombo.SelectedItem.ToString().Equals("S7Net")) + { + TXTip.Enabled = true; + TXTport.Enabled = false; + TXTip.Text = "192.168.0.102"; + TXTport.Text = "102"; + } } private void Form1_FormClosing(object sender, FormClosingEventArgs e) diff --git a/CMS_CORE_Library/S7Net/Nc_S7Net.cs b/CMS_CORE_Library/S7Net/Nc_S7Net.cs index 0c9a9e4..eea7d2c 100644 --- a/CMS_CORE_Library/S7Net/Nc_S7Net.cs +++ b/CMS_CORE_Library/S7Net/Nc_S7Net.cs @@ -1,6 +1,5 @@ using CMS_CORE_Library.Models; using S7.Net; -using Siemens.Sinumerik.Operate.Services; using System; using System.Collections; using System.Collections.Generic; @@ -125,8 +124,10 @@ namespace CMS_CORE_Library.S7Net /// ///Instantiate The NC-S7Net Class /// + /// Remote Ip-Address of the Nc + /// Remote Port of the Nc ///Send/Recieve timeout connection [mS] - public Nc_S7Net(ushort ConnectionTimeOut) + public Nc_S7Net( string IpAddress, ushort RemotePort, ushort ConnectionTimeOut) { //Setup options this.EnableAlarms = true; @@ -137,7 +138,9 @@ namespace CMS_CORE_Library.S7Net this.EnableAxes = false; - //Setup timeout + // Setup parametri + Ip = IpAddress; + Port = RemotePort; TimeoutConn = ConnectionTimeOut; // mesasggi generici PLC PlcMessages = new Dictionary(); @@ -146,6 +149,8 @@ namespace CMS_CORE_Library.S7Net /// /// Instantiate The NC-Siemens Class /// + /// Remote Ip-Address of the Nc + /// Remote Port of the Nc /// Send/Recieve timeout connection [mS] /// Enable Axes Svc /// Enable Alarms Svc @@ -153,7 +158,7 @@ namespace CMS_CORE_Library.S7Net /// Enable Modules Svc /// Enable Parameters Svc /// Enable Prod Svc - public Nc_S7Net(ushort ConnectionTimeOut, bool EnableAxes, bool EnableAlarms, bool EnableHeaters, bool EnableModules, bool EnableParameters, bool EnableProd) + public Nc_S7Net(string IpAddress, ushort RemotePort, ushort ConnectionTimeOut, bool EnableAxes, bool EnableAlarms, bool EnableHeaters, bool EnableModules, bool EnableParameters, bool EnableProd) { //Setup options this.EnableAlarms = EnableAlarms; @@ -163,7 +168,9 @@ namespace CMS_CORE_Library.S7Net this.EnableParameters = EnableParameters; this.EnableProd = EnableProd; - //Setup timeout + // Setup parametri + Ip = IpAddress; + Port = RemotePort; TimeoutConn = ConnectionTimeOut; // mesasggi generici PLC PlcMessages = new Dictionary(); From ba59960af8244a011a03ed2ed82e1313314266d0 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 12 May 2020 13:09:16 +0200 Subject: [PATCH 03/12] Giro con demo... --- CMS_CORE_Library/S7Net/Nc_S7Net.cs | 118 ++++++++++++++++++++--------- 1 file changed, 82 insertions(+), 36 deletions(-) diff --git a/CMS_CORE_Library/S7Net/Nc_S7Net.cs b/CMS_CORE_Library/S7Net/Nc_S7Net.cs index eea7d2c..b2cacd3 100644 --- a/CMS_CORE_Library/S7Net/Nc_S7Net.cs +++ b/CMS_CORE_Library/S7Net/Nc_S7Net.cs @@ -127,7 +127,7 @@ namespace CMS_CORE_Library.S7Net /// Remote Ip-Address of the Nc /// Remote Port of the Nc ///Send/Recieve timeout connection [mS] - public Nc_S7Net( string IpAddress, ushort RemotePort, ushort ConnectionTimeOut) + public Nc_S7Net(string IpAddress, ushort RemotePort, ushort ConnectionTimeOut) { //Setup options this.EnableAlarms = true; @@ -158,7 +158,7 @@ namespace CMS_CORE_Library.S7Net /// Enable Modules Svc /// Enable Parameters Svc /// Enable Prod Svc - public Nc_S7Net(string IpAddress, ushort RemotePort, ushort ConnectionTimeOut, bool EnableAxes, bool EnableAlarms, bool EnableHeaters, bool EnableModules, bool EnableParameters, bool EnableProd) + public Nc_S7Net(string IpAddress, ushort RemotePort, ushort ConnectionTimeOut, bool EnableAxes, bool EnableAlarms, bool EnableHeaters, bool EnableModules, bool EnableParameters, bool EnableProd) { //Setup options this.EnableAlarms = EnableAlarms; @@ -170,7 +170,7 @@ namespace CMS_CORE_Library.S7Net // Setup parametri Ip = IpAddress; - Port = RemotePort; + Port = RemotePort; TimeoutConn = ConnectionTimeOut; // mesasggi generici PLC PlcMessages = new Dictionary(); @@ -688,7 +688,49 @@ namespace CMS_CORE_Library.S7Net { // leggo bitmap allarmi e valorizzo con configurazione + // FIXME!!!! +#if false + //Check if the NC is Connected + CmsError cmsError = CheckConnection(); + if (cmsError.IsError()) + return cmsError; + ushort nReturn; + + //Try to get information + try + { + //Clear the OLD Message + alarms.Clear(); + + //Execute the method + nReturn = OpenNC.ReadCurrentEmergMsg(0, out MSGEMERGENCY errEmgy, out uint errorClass, out uint errorNum); + + //If there's an error launch exception + if (errorClass != 0 || errorNum != 0 || nReturn == 0) + return GetNCError(errorClass, errorNum); + + //If there's an error + if (errEmgy.CodeErr != 0) + { + MESSAGE_TEXT MessageEmgy = new MESSAGE_TEXT(); + Cndex.MSG_EMERGENCY CndexErrorEmgy = ConverToCndexMessage(errEmgy); + + //Translate using OSAI .DLL (a new one!) + OSAIErrorManagerLibrary.TranslateEmergMsg(ref CndexErrorEmgy, ref MessageEmgy); + + //Add alarm to list with the new converted string message + AddNcAlarmToList((ushort)CndexErrorEmgy.Code_Err, OsaiToStepMessage(MessageEmgy), DateTime.Now, alarms); + } + } + catch (Exception ex) + { + return ManageException(ex); + } + + return NO_ERROR; + +#endif #if false alarms = SiemensAlarms. @@ -715,28 +757,8 @@ namespace CMS_CORE_Library.S7Net // Set the Nc Active Page of the NC public override CmsError NC_SetScreenVisible(SCREEN_PAGE screen) { - //Waiting time - int SleepMs = 50; - int TotalTimes = 2000 / 50; - int ActualTimes = 0; - string area = ConvertStepToSiemensScreen(screen); - if (string.IsNullOrEmpty(area)) - return INCORRECT_PARAMETERS_ERROR; - - if (Infrastructure.CurrentActiveArea != area) - { - Infrastructure.SwitchToArea(area); - while (Infrastructure.CurrentActiveArea != area) - { - if (ActualTimes == TotalTimes) - return HMI_NOT_RESPONDING_ERROR; - Thread.Sleep(SleepMs); - ActualTimes++; - } - } - - return NO_ERROR; + return FUNCTION_NOT_ALLOWED_ERROR; } public override CmsError NC_WMDICommand(int processId, string mdiString) @@ -745,6 +767,7 @@ namespace CMS_CORE_Library.S7Net CmsError cmsError = CheckConnection(); if (cmsError.IsError()) return cmsError; +#if false try { FileSvc fileSvc = new FileSvc(); @@ -754,7 +777,8 @@ namespace CMS_CORE_Library.S7Net catch (Exception ex) { return ManageException(ex); - } + } +#endif return NO_ERROR; } @@ -1276,12 +1300,13 @@ namespace CMS_CORE_Library.S7Net // Set button with -> id = 1..5 -> value = parameter value Dictionary buttons = parameters.Skip(2)?.ToDictionary(x => i++, x => x); +#if false // Read machine variable DataSvc dataSvc = new DataSvc(); Item item = new Item() { Path = string.Format("/channel/parameter/r[c{0} , 155]", processId), - }; + }; dataSvc.Read(item); @@ -1294,6 +1319,7 @@ namespace CMS_CORE_Library.S7Net Value = Convert.ToDouble(item.Value), Buttons = buttons }); +#endif } catch (Exception ex) { @@ -1326,6 +1352,7 @@ namespace CMS_CORE_Library.S7Net public override CmsError PLC_WOperatorInputResponse(int process, double responseVal) { +#if false try { DataSvc dataSvc = new DataSvc(); @@ -1342,7 +1369,9 @@ namespace CMS_CORE_Library.S7Net catch (Exception ex) { return ManageException(ex); - } + } +#endif + return FUNCTION_NOT_ALLOWED_ERROR; } public override CmsError PLC_RM154Data(ref List data, ref bool MTCOnOff) @@ -1410,6 +1439,7 @@ namespace CMS_CORE_Library.S7Net { if (bits[processId - 1]) { +#if false Item item = new Item() { Path = string.Format("/channel/parameter/r[c{0} , 154]", processId), @@ -1430,7 +1460,8 @@ namespace CMS_CORE_Library.S7Net Process = (uint)processId, Id = vals.ElementAt(processId - 1), Value = Convert.ToDouble(item.Value) - }); + }); +#endif } } @@ -1518,6 +1549,9 @@ namespace CMS_CORE_Library.S7Net public override CmsError PLC_RScadaSiemens(ref List objects) { + return FUNCTION_NOT_ALLOWED_ERROR; + +#if false try { List items = new List(); @@ -1664,7 +1698,8 @@ namespace CMS_CORE_Library.S7Net return ManageException(ex); } - return NO_ERROR; + return NO_ERROR; +#endif } public override CmsError PLC_WScadaValue(string memIndex, SCADA_MEM_TYPE memType, object value) @@ -2197,6 +2232,10 @@ namespace CMS_CORE_Library.S7Net if (processId <= 0) return PROC_NOT_FOUND_ERROR; + // FIXME + // ha senso? + +#if false try { Item[] items = new Item[7] @@ -2313,13 +2352,17 @@ namespace CMS_CORE_Library.S7Net catch (Exception ex) { return ManageException(ex); - } + } +#endif return NO_ERROR; } private CmsError PROC_ReadActiveLine(uint processId, ref string line) { + return FUNCTION_NOT_ALLOWED_ERROR; + +#if false try { Item item = new Item(); @@ -2338,7 +2381,8 @@ namespace CMS_CORE_Library.S7Net return ManageException(ex); } - return NO_ERROR; + return NO_ERROR; +#endif } #endregion PROCESS (PATH) High-level data @@ -2705,7 +2749,7 @@ namespace CMS_CORE_Library.S7Net { Value = (bValue & pow) == pow; } - + return NO_ERROR; } @@ -3947,11 +3991,10 @@ namespace CMS_CORE_Library.S7Net #region Subordinate Private Functions - +#if false // Manage the Alarms - Called automatically on changes private void AlarmsChanged(Guid guid, Alarm[] alarms) { -#if false try { if (alarms != null) @@ -3961,8 +4004,8 @@ namespace CMS_CORE_Library.S7Net { Console.WriteLine(ex.Message); } + } #endif - } private void NcLanguageChanged(string language) { @@ -4159,9 +4202,12 @@ namespace CMS_CORE_Library.S7Net Cms_MachNumber = ((uint)ItemMachineNumber.Value).ToString(); UnitOfMeasure = (uint)ItemUnitOfMeasure.Value == 0 ? MILLIMETERS : INCHES; +#endif //Save NOW Last_Static_Read = DateTime.Now; -#endif + Cnc_name = $"{currPLC.CPU}"; + Cnc_SftVersion = "0.0.0"; + Cnc_SeriesNum = "000"; } catch (Exception ex) { From 2a440ae2c5eca3cb622c5a1ff7c319d8951040f4 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 12 May 2020 17:23:15 +0200 Subject: [PATCH 04/12] fix display demo app --- CMS_CORE_Application/Form1.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMS_CORE_Application/Form1.cs b/CMS_CORE_Application/Form1.cs index 3927645..80836d9 100644 --- a/CMS_CORE_Application/Form1.cs +++ b/CMS_CORE_Application/Form1.cs @@ -78,6 +78,9 @@ namespace CMS_CORE_Application CmsError cmsError = N.NC_Connect(); cmsError = N.NC_RModelName(ref ModelName); + cmsError = N.NC_RSoftwareVersion(ref SFTVersion); + cmsError = N.NC_RSerialNumber(ref MachNumber); + List val = new List(); From db6a7875946090b9fe8e8e6dfd7bca7b47ed7c24 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 15 May 2020 17:45:37 +0200 Subject: [PATCH 05/12] Fix not available function in S7Net --- CMS_CORE_Library/S7Net/Nc_S7Net.cs | 456 ++++------------------------- 1 file changed, 60 insertions(+), 396 deletions(-) diff --git a/CMS_CORE_Library/S7Net/Nc_S7Net.cs b/CMS_CORE_Library/S7Net/Nc_S7Net.cs index b2cacd3..a768687 100644 --- a/CMS_CORE_Library/S7Net/Nc_S7Net.cs +++ b/CMS_CORE_Library/S7Net/Nc_S7Net.cs @@ -54,20 +54,18 @@ namespace CMS_CORE_Library.S7Net private const string ACT_PROG_LINES_PATH = "/Channel/ProgramInfo/actPartProgram"; private const string ACT_PROG_NAME_PATH = "/Channel/ProgramPointer/progName"; - #endif + // Global Variables private static DateTime Last_Static_Read; - private ushort TimeoutConn; private static string Cnc_name; private static string Cnc_SftVersion; private static string Cnc_SeriesNum; private static string Cms_MachNumber; + private static string PlcRirm_SeriesNum; private static uint ConfChannelNo; - private static uint MaxChannelNo; - private static uint SiemensLanguage; private static string UnitOfMeasure; // Alarms data @@ -141,7 +139,6 @@ namespace CMS_CORE_Library.S7Net // Setup parametri Ip = IpAddress; Port = RemotePort; - TimeoutConn = ConnectionTimeOut; // mesasggi generici PLC PlcMessages = new Dictionary(); } @@ -171,7 +168,6 @@ namespace CMS_CORE_Library.S7Net // Setup parametri Ip = IpAddress; Port = RemotePort; - TimeoutConn = ConnectionTimeOut; // mesasggi generici PLC PlcMessages = new Dictionary(); } @@ -199,21 +195,6 @@ namespace CMS_CORE_Library.S7Net if (AxesSvc == null) AxesSvc = new DataSvc(); } - - if (SelectedProcessSvc == null) - { - SelectedProcessSvc = new DataSvc(); - - SelectedProcessSvc.Subscribe(ManageSelectedProcess, new Item[] - { - new Item() { Path = "DB258.DBX2582.2" }, - new Item() { Path = "DB258.DBX2586.2" }, - new Item() { Path = "DB258.DBX2590.2" }, - new Item() { Path = "DB258.DBX2594.2" }, - new Item() { Path = "DB258.DBX2598.2" }, - new Item() { Path = "DB258.DBX2602.2" }, - }); - } #endif // Setup the alarms (with DB bitmap) --> PlcMessages @@ -229,32 +210,6 @@ namespace CMS_CORE_Library.S7Net #endif } -#if false - if (this.EnableTools) - { - // Setup tooltable listeners - if (SiemensToolSvc == null) - { - SiemensToolSvc = new ToolMngmntSvc(1); - ToolMngmtListGuid = SiemensToolSvc.Subscribe(ToolMngmtSvcHandler); - SetupToolTableData(); - } - - // Setup magazine position listener - if (MagazinePositionSvc == null) - { - MagazinePositionSvc = new DataSvc(); - SetupMagazinePositionListener(); - } - - // Setup magazine action - if (MagazineActionsSvc == null) - { - MagazineActionsSvc = new DataSvc(); - SetupMagazineActionListener(); - } - } -#endif } catch (Exception ex) { @@ -456,41 +411,22 @@ namespace CMS_CORE_Library.S7Net string filePath; try { - messages = new Dictionary(); - + PlcMessages = new Dictionary(); CultureInfo cultureInfo = CultureInfo.CreateSpecificCulture(language); + string langName = ""; + if (cultureInfo.IsNeutralCulture) + langName = cultureInfo.EnglishName; + else + langName = cultureInfo.Parent.EnglishName; - // Setup the path of NC alarms translations file - filePath = PLC_MESSAGES_FILE_PATH + "cmsalarm_" + cultureInfo.ThreeLetterISOLanguageName.ToUpper() + ".ts"; - if (!File.Exists(filePath)) - return INCORRECT_LANGUAGE_ERROR; + //Setup the Path + filePath = PLC_MESSAGE_PATH + @"Messaggi_" + langName + @".txt"; - // Open file reader - XDocument xmlTranslationsFile; - - using (StreamReader oReader = new StreamReader(filePath, Encoding.ASCII)) - { - xmlTranslationsFile = XDocument.Load(oReader); - } - - // Read file with LINQ - var messagesList = xmlTranslationsFile - .Root - .Descendants("context") - .Elements() - .Where(x => x.Name == "message") - .Select(x => new - { - Key = Convert.ToInt32(x.Element("source").Value.Split('/').FirstOrDefault()), - Value = x.Element("translation").Value - }); - - foreach (var message in messagesList) - { - // If not contain key - if (!messages.Keys.Contains(message.Key)) - messages.Add(message.Key, message.Value); - } + //Read From Files + messages = File.ReadAllLines(filePath, Encoding.Default) + .Select(line => line.Split(',')) + .Where(line => line.Count() == 2) + .ToDictionary(line => Convert.ToInt32(line[0]), line => line[1].Trim()); return NO_ERROR; } @@ -538,11 +474,11 @@ namespace CMS_CORE_Library.S7Net return FUNCTION_NOT_ALLOWED_ERROR; } - #endregion Contructor & global methods +#endregion Contructor & global methods /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - #region High level methods +#region High level methods // Get the processes-count configurated public override CmsError NC_RProcessesNum(ref ushort ProcNumber) @@ -583,13 +519,7 @@ namespace CMS_CORE_Library.S7Net // Get the NC Language public override CmsError NC_RLanguage(ref CultureInfo Language) { - CmsError cmsError = ReadStaticNCData(); - if (cmsError.IsError()) - return cmsError; - - Language = ConvertToSTEPLanguage(SiemensLanguage); - - return NO_ERROR; + return FUNCTION_NOT_ALLOWED_ERROR; } // Set the NC Language @@ -686,108 +616,25 @@ namespace CMS_CORE_Library.S7Net // Get the Nc Active Alarms public override CmsError NC_RActiveAlarms(ref List alarms) { - // leggo bitmap allarmi e valorizzo con configurazione - - - // FIXME!!!! -#if false - //Check if the NC is Connected - CmsError cmsError = CheckConnection(); - if (cmsError.IsError()) - return cmsError; - ushort nReturn; - - //Try to get information - try - { - //Clear the OLD Message - alarms.Clear(); - - //Execute the method - nReturn = OpenNC.ReadCurrentEmergMsg(0, out MSGEMERGENCY errEmgy, out uint errorClass, out uint errorNum); - - //If there's an error launch exception - if (errorClass != 0 || errorNum != 0 || nReturn == 0) - return GetNCError(errorClass, errorNum); - - //If there's an error - if (errEmgy.CodeErr != 0) - { - MESSAGE_TEXT MessageEmgy = new MESSAGE_TEXT(); - Cndex.MSG_EMERGENCY CndexErrorEmgy = ConverToCndexMessage(errEmgy); - - //Translate using OSAI .DLL (a new one!) - OSAIErrorManagerLibrary.TranslateEmergMsg(ref CndexErrorEmgy, ref MessageEmgy); - - //Add alarm to list with the new converted string message - AddNcAlarmToList((ushort)CndexErrorEmgy.Code_Err, OsaiToStepMessage(MessageEmgy), DateTime.Now, alarms); - } - } - catch (Exception ex) - { - return ManageException(ex); - } - - return NO_ERROR; - -#endif - -#if false - alarms = SiemensAlarms. - Where(x => (x.Id < IDMinPLCMessage || x.Id > IDMaxPLCMessage) && (x.Id < IDMinChannel || x.Id > IDMaxChannel)) - .Select(x => - { - uint id = x.Instance == 1 ? (uint)x.Id : Convert.ToUInt32((x.Id & 0xffff) | (x.Instance << 24)); - return new AlarmModel() - { - Id = id, - Message = x.Message, - IsWarning = false, - Process = 0, - DateTime = x.TimeStamp - }; - }) - .GroupBy(x => x.Id).Select(x => x.First()) - .ToList(); -#endif - - return NO_ERROR; + return FUNCTION_NOT_ALLOWED_ERROR; } // Set the Nc Active Page of the NC public override CmsError NC_SetScreenVisible(SCREEN_PAGE screen) { - return FUNCTION_NOT_ALLOWED_ERROR; } public override CmsError NC_WMDICommand(int processId, string mdiString) { - // Check if the NC is Connected - CmsError cmsError = CheckConnection(); - if (cmsError.IsError()) - return cmsError; -#if false - try - { - FileSvc fileSvc = new FileSvc(); - var a = fileSvc.ReadMdaBuffer(1); - fileSvc.WriteMdaBuffer(processId, mdiString); - } - catch (Exception ex) - { - return ManageException(ex); - } -#endif - - return NO_ERROR; + return FUNCTION_NOT_ALLOWED_ERROR; } - #endregion High level methods +#endregion High level methods /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - #region PLC High-level data +#region PLC High-level data public override CmsError PLC_RWManageWatchdog() { @@ -1102,35 +949,12 @@ namespace CMS_CORE_Library.S7Net public override CmsError PLC_RWorkedTimeHead(int head, ref uint time) { - int index = (head - 1) * 4; - - // Read Worked time - CmsError cmsError = MEM_RWDWord(R, 0, HEADS_WORKED_TIMES.MemType, HEADS_WORKED_TIMES.Address, HEADS_WORKED_TIMES.SubAddress + index, ref time); - if (cmsError.IsError()) - return cmsError; - - return NO_ERROR; + return FUNCTION_NOT_ALLOWED_ERROR; } public override CmsError PLC_WResetWorkedTimeHead(int head) { - byte usControlWord = 0; - - if (head <= 0 || head > MAX_HEADS_NUMBER) - return INCORRECT_PARAMETERS_ERROR; - - // Read status - CmsError cmsError = MEM_RWByte(R, 0, HEAD_RESET_WORKED_TIME.MemType, HEAD_RESET_WORKED_TIME.Address, HEAD_RESET_WORKED_TIME.SubAddress, 0, ref usControlWord); - if (cmsError.IsError()) - return cmsError; - - // Re-Write it status - usControlWord = Convert.ToByte((usControlWord & 0xE0) | (head & 0X1F)); - cmsError = MEM_RWByte(W, 0, HEAD_RESET_WORKED_TIME.MemType, HEAD_RESET_WORKED_TIME.Address, HEAD_RESET_WORKED_TIME.SubAddress, 0, ref usControlWord); - if (cmsError.IsError()) - return cmsError; - - return NO_ERROR; + return FUNCTION_NOT_ALLOWED_ERROR; } public override CmsError PLC_RWorkedTimeMachine(ref uint time) @@ -1201,17 +1025,7 @@ namespace CMS_CORE_Library.S7Net public override CmsError PLC_WHeadOverride(uint id, HEAD_OVERRIDE_SIGN sign) { - if (id > MAX_HEADS_NUMBER) - return INCORRECT_PARAMETERS_ERROR; - - MEMORY_CELL currentStrobeCell = sign == HEAD_OVERRIDE_SIGN.PLUS ? HEADS_STROBE_INCREMENT : HEADS_STROBE_DECREMENT; - - // Write strobe into memory - CmsError cmsError = PLC_WStrobe(HEADS_ACK, currentStrobeCell, id); - if (cmsError.IsError()) - return cmsError; - - return NO_ERROR; + return FUNCTION_NOT_ALLOWED_ERROR; } // MACHINE COUNTERS @@ -1254,123 +1068,11 @@ namespace CMS_CORE_Library.S7Net public override CmsError PLC_ROperatorInputIsNeeded(ref List value) { - byte val = 0; - // Read memory - CmsError cmsError = MEM_RWByte(R, 0, M155_INPUT_NEEDED.MemType, M155_INPUT_NEEDED.Address, M155_INPUT_NEEDED.SubAddress, 0, ref val); - if (cmsError.IsError()) - return cmsError; - // Convert byte to an array of bits - bool[] bits = ByteToBits(val); - uint processId = 1; - - string[] parameters; - string actualLine = ""; - - foreach (bool bit in bits) - { - if (bit) - { - // Read active program line - cmsError = PROC_ReadActiveLine(processId, ref actualLine); - if (cmsError.IsError()) - return cmsError; - - // Parse line & get parameters - parameters = ExtractM155ParametersFromNcCodeLine(actualLine); - if (parameters.Count() == 0) - { - value.Add(new M155InputIsNeededModel() - { - Process = processId, - IsNeeded = bits[processId - 1], - Message = "", - Type = M155_TYPE.REAL, - Buttons = new Dictionary() - }); - - return NO_ERROR; - } - - byte i = 1; - if (parameters[0].ToUpper().Trim() == "SHOWVAL") - { - try - { - // Skip first parameter because it's the message string - // Set button with -> id = 1..5 -> value = parameter value - Dictionary buttons = parameters.Skip(2)?.ToDictionary(x => i++, x => x); - -#if false - // Read machine variable - DataSvc dataSvc = new DataSvc(); - Item item = new Item() - { - Path = string.Format("/channel/parameter/r[c{0} , 155]", processId), - }; - - dataSvc.Read(item); - - value.Add(new M155InputIsNeededModel() - { - Process = processId, - IsNeeded = bits[processId - 1], - Message = parameters[1] ?? "", - Type = M155_TYPE.SHOW_VAL, // if there aren't buttons is a simple request, - Value = Convert.ToDouble(item.Value), - Buttons = buttons - }); -#endif - } - catch (Exception ex) - { - return ManageException(ex); - } - } - else - { - // Skip first parameter because it's the message string - // Set button with -> id = 1..5 -> value = parameter value - Dictionary buttons = parameters.Skip(1)?.ToDictionary(x => i++, x => x); - - value.Add(new M155InputIsNeededModel() - { - Process = processId, - IsNeeded = bit, - Message = parameters[0] ?? "", - Type = parameters.Count() > 1 ? M155_TYPE.MULTIPLE_BUTTONS : M155_TYPE.REAL, // if there aren't buttons is a simple request - Buttons = buttons - }); - } - } - - // Next path - processId++; - } - - return NO_ERROR; + return FUNCTION_NOT_ALLOWED_ERROR; } public override CmsError PLC_WOperatorInputResponse(int process, double responseVal) { -#if false - try - { - DataSvc dataSvc = new DataSvc(); - Item item = new Item() - { - Path = string.Format("/channel/parameter/r[c{0} , 155]", process), - Value = responseVal - }; - - dataSvc.Write(item); - - return PLC_WStrobe(M155_INPUT_ACK, M155_INPUT_STROBE, (uint)process); - } - catch (Exception ex) - { - return ManageException(ex); - } -#endif return FUNCTION_NOT_ALLOWED_ERROR; } @@ -2017,11 +1719,11 @@ namespace CMS_CORE_Library.S7Net return FUNCTION_NOT_ALLOWED_ERROR; } - #endregion PLC High-level data +#endregion PLC High-level data /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - #region PROCESS (PATH) High-level data +#region PROCESS (PATH) High-level data // Get the process Mode public override CmsError PROC_RMode(ushort ProcNumber, ref PROC_MODE Mode) @@ -2385,11 +2087,11 @@ namespace CMS_CORE_Library.S7Net #endif } - #endregion PROCESS (PATH) High-level data +#endregion PROCESS (PATH) High-level data /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - #region PROCESS-AXES (PATH) High-level data +#region PROCESS-AXES (PATH) High-level data public override CmsError AXES_RInterpPosition(ushort channel, ref Dictionary axes) { @@ -2705,11 +2407,11 @@ namespace CMS_CORE_Library.S7Net #endif } - #endregion PROCESS-AXES (PATH) High-level data +#endregion PROCESS-AXES (PATH) High-level data /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - #region NC Low-level function: single valiable in memory +#region NC Low-level function: single valiable in memory //Read-Write a Boolean-Value inside the NC. public override CmsError MEM_RWBoolean(bool bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, int MemBit, ref bool Value) @@ -2904,11 +2606,11 @@ namespace CMS_CORE_Library.S7Net return FUNCTION_NOT_ALLOWED_ERROR; } - #endregion NC Low-level function: single valiable in memory +#endregion NC Low-level function: single valiable in memory /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - #region Low level methods +#region Low level methods public override CmsError MEM_RWByteList(bool bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, int MemByteStart, int Number, ref List Values) { @@ -3210,11 +2912,11 @@ namespace CMS_CORE_Library.S7Net return NO_ERROR; } - #endregion Low level methods +#endregion Low level methods /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - #region NC Low-level function: Parameters +#region NC Low-level function: Parameters public override CmsError NC_RParam(short Index, short Bit, ref bool Value) { @@ -3241,11 +2943,11 @@ namespace CMS_CORE_Library.S7Net return FUNCTION_NOT_ALLOWED_ERROR; } - #endregion NC Low-level function: Parameters +#endregion NC Low-level function: Parameters /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - #region File Management +#region File Management /// /// Get list of recipe (from local PC area) @@ -3728,11 +3430,11 @@ namespace CMS_CORE_Library.S7Net return path.Replace('\\', '/'); } - #endregion File Management +#endregion File Management /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - #region Siemens Tools Management +#region Siemens Tools Management public override CmsError TOOLS_RConfiguration(ref ToolTableConfiguration config) { @@ -3879,11 +3581,11 @@ namespace CMS_CORE_Library.S7Net return FUNCTION_NOT_ALLOWED_ERROR; } - #endregion Siemens Tools Management +#endregion Siemens Tools Management /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - #region Nc Tool Manager +#region Nc Tool Manager public override CmsError TOOLS_RMagazineConfig(ref List config) { @@ -3985,11 +3687,11 @@ namespace CMS_CORE_Library.S7Net return FUNCTION_NOT_ALLOWED_ERROR; } - #endregion Nc Tool Manager +#endregion Nc Tool Manager /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - #region Subordinate Private Functions +#region Subordinate Private Functions #if false // Manage the Alarms - Called automatically on changes @@ -4166,48 +3868,16 @@ namespace CMS_CORE_Library.S7Net //Try to get information try { -#if false - DataSvc ReadStaticData = DefaultPriorityDataSvc(); - Item ItemNcType = new Item(NC_TYPE_PATH); - Item ItemNcVersion = new Item(NC_VERSION_PATH); - Item ItemMaxChannelNo = new Item(MAX_CHANNEL_NO_PATH); - Item ItemConfChannelNo = new Item(CONF_CHANNEL_NO_PATH); - Item ItemLanguage = new Item(LANGUAGE_PATH); - Item ItemSerialNumber = new Item(SERIAL_NO_PATH); - Item ItemUnitOfMeasure = new Item(UNIT_OF_MEASURE); - cmsError = ConvertMemToPath(MATR_MACCH_SIEMENS.MemType, MATR_MACCH_SIEMENS.Address, MATR_MACCH_SIEMENS.SubAddress, 0, 1, 'W', out string itemString); - - if (cmsError.IsError()) - return cmsError; - Item ItemMachineNumber = new Item(itemString); - - //Read All Data - ReadStaticData.Read(ItemNcType); - ReadStaticData.Read(ItemNcVersion); - ReadStaticData.Read(ItemMaxChannelNo); - ReadStaticData.Read(ItemConfChannelNo); - ReadStaticData.Read(ItemLanguage); - ReadStaticData.Read(ItemSerialNumber); - ReadStaticData.Read(ItemMachineNumber); - ReadStaticData.Read(ItemUnitOfMeasure); - - //Setup variables - Cnc_name = GetName((uint)ItemNcType.Value); - Cnc_SftVersion = Regex.Replace(((double)ItemNcVersion.Value).ToString(), ".{2}", "$0.").TrimEnd('.'); ; - Cnc_SeriesNum = ((string)ItemSerialNumber.Value); - - MaxChannelNo = (uint)ItemMaxChannelNo.Value; - ConfChannelNo = (uint)ItemConfChannelNo.Value; - SiemensLanguage = (uint)ItemLanguage.Value; - Cms_MachNumber = ((uint)ItemMachineNumber.Value).ToString(); - UnitOfMeasure = (uint)ItemUnitOfMeasure.Value == 0 ? MILLIMETERS : INCHES; - -#endif - //Save NOW + // completare nuove variabili (matricola macchina, seriale PLC, firmware PLC) + ConfChannelNo = 1; Last_Static_Read = DateTime.Now; Cnc_name = $"{currPLC.CPU}"; - Cnc_SftVersion = "0.0.0"; - Cnc_SeriesNum = "000"; + // FIXME + Cms_MachNumber = ""; // matricola macchina, DB604.DBB6720..6723 + Cnc_SftVersion = "SMC000"; // versione SW del firmware PLC/CNC | DB604.DBB6724..6745 + Cnc_SeriesNum = "SMC111"; // seriale PLC/CNC | DB604.DBB6746..6763 + PlcRirm_SeriesNum = "V.0.0.0"; // seriale PLC/CNC | DB604.DBB6764..6767 + UnitOfMeasure = MILLIMETERS; } catch (Exception ex) { @@ -4373,7 +4043,7 @@ namespace CMS_CORE_Library.S7Net } } - #endregion Subordinate Private Functions +#endregion Subordinate Private Functions /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -4382,6 +4052,9 @@ namespace CMS_CORE_Library.S7Net internal static class MEMORY_ADDRESS { + // Tabella DB principale + internal const int TABLE = 604; + // aree Parametri internal static MEMORY_CELL PARAMETER_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 600, 20, 8000); internal static MEMORY_CELL PARAMETER_RT_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 601, 8, 3200); @@ -4399,12 +4072,13 @@ namespace CMS_CORE_Library.S7Net internal static MEMORY_CELL RISC_ESP_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 500, 9728, 1024); internal static MEMORY_CELL RISC_OVP_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 500, 10752, 1024); internal static MEMORY_CELL RISC_ICH_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 500, 11776, 4096); - + // produzione internal static MEMORY_CELL PROCESS_STATUS = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 605, 0, 2); - // ciclo produzione - internal const int TABLE = 604; + // Machine number + internal static MEMORY_CELL NEW_MATR_MACC = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 604, 6720, 4); + @@ -4475,9 +4149,6 @@ namespace CMS_CORE_Library.S7Net internal static MEMORY_CELL MAGAZINE_ACTION = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 4000, 16); - internal static MEMORY_CELL BALLUF_ACTION_ACK = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 4014, 1); - internal static MEMORY_CELL BALLUF_ACTION_STROBE = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 4015, 1); - internal static MEMORY_CELL BALLUF_ACTION_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 4016, 1); //old CMS-Control variables internal static MEMORY_CELL HEADS_WORKED_TIMES = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 254, 60, 4); @@ -4488,12 +4159,5 @@ namespace CMS_CORE_Library.S7Net internal static MEMORY_CELL EXP_CANDY_MEM = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 255, 92, 1); - internal static MEMORY_CELL SELF_ADAPTIVE_PATH = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 253, 16, 4); - - internal static MEMORY_CELL BALLUF_EMPTY_TABLE = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 111, 0, 486); - - // Machine number - internal static MEMORY_CELL MATR_MACCH_SIEMENS = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 255, 0, 1); - internal static MEMORY_CELL NEW_MATR_MACC = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 258, 3060, 4); } } \ No newline at end of file From d81c738ea1ccf2db6f1ad024921bb93e71bbc57b Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 15 May 2020 18:39:10 +0200 Subject: [PATCH 06/12] New THERMO data structures --- CMS_CORE_Library/Models/DataStructures.cs | 87 +++++++++++++++++++++-- 1 file changed, 81 insertions(+), 6 deletions(-) diff --git a/CMS_CORE_Library/Models/DataStructures.cs b/CMS_CORE_Library/Models/DataStructures.cs index 4e6aa2b..e2ffca3 100644 --- a/CMS_CORE_Library/Models/DataStructures.cs +++ b/CMS_CORE_Library/Models/DataStructures.cs @@ -95,7 +95,7 @@ namespace CMS_CORE_Library.Models REVOLVER = 3, BOX_MAGAZINE = 5, MAGAZINE_TOOL_BUFFER = 7, - MAGAZINE_LOADING_STATION = 9, + MAGAZINE_LOADING_STATION = 9, INVISIBLE_MAGAZINE = 99 } @@ -178,7 +178,7 @@ namespace CMS_CORE_Library.Models public static CmsError INCORRECT_PARAMETERS_ERROR = new CmsError(CMS_ERROR_CODES.INCORRECT_PARAMETERS, "error_incorrect_parameters"); public static CmsError INCORRECT_LANGUAGE_ERROR = new CmsError(CMS_ERROR_CODES.NC_LANGUAGE_ERROR, "error_invalid_language"); public static CmsError SIEMENS_ENVIRONMENT_NOT_FOUND_ERROR = new CmsError(CMS_ERROR_CODES.SIEMENS_ENVIRONMENT_NOT_FOUND, "error_siemens_enviroment_not_found_error"); - public static CmsError PLC_IP_NOT_FOUND_ERROR = new CmsError(CMS_ERROR_CODES.PLC_IP_NOT_FOUND, "error_plc_ip_not_found_error"); + public static CmsError PLC_IP_NOT_FOUND_ERROR = new CmsError(CMS_ERROR_CODES.PLC_IP_NOT_FOUND, "error_plc_ip_not_found_error"); public static CmsError SIEMENS_HMI_NOT_RUNNING_ERROR = new CmsError(CMS_ERROR_CODES.SIEMENS_HMI_NOT_RUNNING, "error_siemens_hmi_not_running"); public static CmsError MAX_TOOL_REACHED_ERROR = new CmsError(CMS_ERROR_CODES.MAX_TOOL_REACHED, "error_max_tool_reached"); public static CmsError MAX_EDGES_PER_TOOL_REACHED_ERROR = new CmsError(CMS_ERROR_CODES.MAX_EDGES_PER_TOOL_REACHED, "error_max_edges_per_tool_reached"); @@ -190,7 +190,7 @@ namespace CMS_CORE_Library.Models public static CmsError MAGAZINE_BUSY_ERROR = new CmsError(CMS_ERROR_CODES.MAGAZINE_OCCUPIED, "error_magazine_occupied"); public static CmsError TOOL_IS_MOUNTED_ERROR = new CmsError(CMS_ERROR_CODES.TOOL_IS_MOUNTED, "error_tool_mounted"); public static CmsError TOOL_AND_POSITION_NOT_MATCHING_ERROR = new CmsError(CMS_ERROR_CODES.TOOL_IS_MOUNTED, "error_tool_and_position_not_matching"); - public static CmsError FILE_NOT_FOUND_ERROR = new CmsError(CMS_ERROR_CODES.FILE_NOT_FOUND, "error_file_not_found"); + public static CmsError FILE_NOT_FOUND_ERROR = new CmsError(CMS_ERROR_CODES.FILE_NOT_FOUND, "error_file_not_found"); public static CmsError PLC_NOT_RUNNING_ERROR = new CmsError(CMS_ERROR_CODES.PLC_NOT_RUNNING, "error_plc_not_running"); public static CmsError HMI_NOT_RESPONDING_ERROR = new CmsError(CMS_ERROR_CODES.HMI_NOT_RESPONDING, "error_hmi_not_responding"); public static CmsError PROGRAM_IS_SELECTED_ERROR = new CmsError(CMS_ERROR_CODES.PROGRAM_IS_SELECTED, "error_program_is_selected"); @@ -359,7 +359,7 @@ namespace CMS_CORE_Library.Models } public class HeadDataModel - { + { public uint Id; public byte Process; public byte Override; @@ -424,7 +424,7 @@ namespace CMS_CORE_Library.Models { public short Origin { get; set; } - public short ActiveOffsetId { get; set; } + public short ActiveOffsetId { get; set; } public string ProcessMessage { get; set; } @@ -462,7 +462,7 @@ namespace CMS_CORE_Library.Models TRANSFER_WITHOUT_ORIG = 2, SWITCH = 3 } - + public enum MOVEMENT_RESPONSE { NONE = 0, @@ -520,5 +520,80 @@ namespace CMS_CORE_Library.Models } #endregion Data structure models + + #region Thermo models + + + public class RecipeParam + { + public ushort Id { get; set; } + public int SetpointHMI { get; set; } + public int SetpointPLC { get; set; } + public double ValMax { get; set; } + public double ValMin { get; set; } + public string UnitMeasure { get; set; } + public bool Visible { get; set; } + public bool Enabled { get; set; } + public bool HasError { get; set; } + public double ValueAct { get; set; } + } + + + public class RecipeModule + { + public ushort Id { get; set; } + public uint EstimatedDuration { get; set; } + public uint EstimatedDelay { get; set; } + public List PrecedingId { get; set; } + public uint ActualDuration { get; set; } + public uint ActualDelay { get; set; } + public bool Visible { get; set; } + public bool Running { get; set; } + public bool HasError { get; set; } + } + + public class RecipeWarmerUp + { + public ushort Id { get; set; } + public byte IdRefrector { get; set; } + public double MinCurrent { get; set; } + public byte ChStatus { get; set; } + public byte PercWork { get; set; } + public byte PercAct { get; set; } + } + + public class RecipeWarmerDown + { + public ushort Id { get; set; } + public byte SetpointHMI { get; set; } + } + + + public class RecipeProdInfo + { + public ushort NumTarget { get; set; } + public ushort NumDOne { get; set; } + public uint TimeWarm { get; set; } + public uint TimeVent { get; set; } + public uint TimeVacuum { get; set; } + public uint TimeCycleGross { get; set; } + public uint TimeCycleNet { get; set; } + public double MaterialTempEndWarm { get; set; } + public double MaterialTempEndVent { get; set; } + public double MoldTemp { get; set; } + public double VacuumReadVal { get; set; } + public double MouldEnergyOUT { get; set; } + public double MouldEnergyIN { get; set; } + } + + public class RecipeProdCycle + { + public ushort Status { get; set; } + public ushort MessageId { get; set; } + public ushort Mode { get; set; } + public uint TimeAdv { get; set; } + } + + #endregion } } \ No newline at end of file From 6ed6afe4208d41ebb30c8236fcba57e4148f5296 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 15 May 2020 18:39:21 +0200 Subject: [PATCH 07/12] Start high level thermo methods --- CMS_CORE_Library/S7Net/Nc_S7Net.cs | 93 ++++++++++++++++++++++-------- 1 file changed, 68 insertions(+), 25 deletions(-) diff --git a/CMS_CORE_Library/S7Net/Nc_S7Net.cs b/CMS_CORE_Library/S7Net/Nc_S7Net.cs index a768687..aa853fd 100644 --- a/CMS_CORE_Library/S7Net/Nc_S7Net.cs +++ b/CMS_CORE_Library/S7Net/Nc_S7Net.cs @@ -71,6 +71,7 @@ namespace CMS_CORE_Library.S7Net // Alarms data private static Dictionary PlcMessages; + #if false private const string PLC_MESSAGES_FILE_PATH = "C:\\Program Files (x86)\\Siemens\\MotionControl\\oem\\sinumerik\\hmi\\lng\\"; @@ -106,6 +107,11 @@ namespace CMS_CORE_Library.S7Net private bool EnableAxes; + + // parametri specifici per THERMO + private static List thermoParamList; + + // connessione S7 private CpuType tipoCpu = CpuType.S71500; private short rack = 0; private short slot = 1; @@ -141,6 +147,7 @@ namespace CMS_CORE_Library.S7Net Port = RemotePort; // mesasggi generici PLC PlcMessages = new Dictionary(); + thermoParamList = new List(); } /// @@ -170,6 +177,7 @@ namespace CMS_CORE_Library.S7Net Port = RemotePort; // mesasggi generici PLC PlcMessages = new Dictionary(); + thermoParamList = new List(); } public override CmsError NC_Connect() @@ -474,11 +482,11 @@ namespace CMS_CORE_Library.S7Net return FUNCTION_NOT_ALLOWED_ERROR; } -#endregion Contructor & global methods + #endregion Contructor & global methods /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#region High level methods + #region High level methods // Get the processes-count configurated public override CmsError NC_RProcessesNum(ref ushort ProcNumber) @@ -630,11 +638,11 @@ namespace CMS_CORE_Library.S7Net return FUNCTION_NOT_ALLOWED_ERROR; } -#endregion High level methods + #endregion High level methods /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#region PLC High-level data + #region PLC High-level data public override CmsError PLC_RWManageWatchdog() { @@ -1719,11 +1727,11 @@ namespace CMS_CORE_Library.S7Net return FUNCTION_NOT_ALLOWED_ERROR; } -#endregion PLC High-level data + #endregion PLC High-level data /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#region PROCESS (PATH) High-level data + #region PROCESS (PATH) High-level data // Get the process Mode public override CmsError PROC_RMode(ushort ProcNumber, ref PROC_MODE Mode) @@ -2087,11 +2095,11 @@ namespace CMS_CORE_Library.S7Net #endif } -#endregion PROCESS (PATH) High-level data + #endregion PROCESS (PATH) High-level data /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#region PROCESS-AXES (PATH) High-level data + #region PROCESS-AXES (PATH) High-level data public override CmsError AXES_RInterpPosition(ushort channel, ref Dictionary axes) { @@ -2407,11 +2415,11 @@ namespace CMS_CORE_Library.S7Net #endif } -#endregion PROCESS-AXES (PATH) High-level data + #endregion PROCESS-AXES (PATH) High-level data /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#region NC Low-level function: single valiable in memory + #region NC Low-level function: single valiable in memory //Read-Write a Boolean-Value inside the NC. public override CmsError MEM_RWBoolean(bool bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, int MemBit, ref bool Value) @@ -2606,11 +2614,11 @@ namespace CMS_CORE_Library.S7Net return FUNCTION_NOT_ALLOWED_ERROR; } -#endregion NC Low-level function: single valiable in memory + #endregion NC Low-level function: single valiable in memory /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#region Low level methods + #region Low level methods public override CmsError MEM_RWByteList(bool bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, int MemByteStart, int Number, ref List Values) { @@ -2912,11 +2920,11 @@ namespace CMS_CORE_Library.S7Net return NO_ERROR; } -#endregion Low level methods + #endregion Low level methods /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#region NC Low-level function: Parameters + #region NC Low-level function: Parameters public override CmsError NC_RParam(short Index, short Bit, ref bool Value) { @@ -2943,11 +2951,11 @@ namespace CMS_CORE_Library.S7Net return FUNCTION_NOT_ALLOWED_ERROR; } -#endregion NC Low-level function: Parameters + #endregion NC Low-level function: Parameters /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#region File Management + #region File Management /// /// Get list of recipe (from local PC area) @@ -3430,11 +3438,11 @@ namespace CMS_CORE_Library.S7Net return path.Replace('\\', '/'); } -#endregion File Management + #endregion File Management /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#region Siemens Tools Management + #region Siemens Tools Management public override CmsError TOOLS_RConfiguration(ref ToolTableConfiguration config) { @@ -3581,11 +3589,11 @@ namespace CMS_CORE_Library.S7Net return FUNCTION_NOT_ALLOWED_ERROR; } -#endregion Siemens Tools Management + #endregion Siemens Tools Management /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#region Nc Tool Manager + #region Nc Tool Manager public override CmsError TOOLS_RMagazineConfig(ref List config) { @@ -3687,11 +3695,11 @@ namespace CMS_CORE_Library.S7Net return FUNCTION_NOT_ALLOWED_ERROR; } -#endregion Nc Tool Manager + #endregion Nc Tool Manager /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -#region Subordinate Private Functions + #region Subordinate Private Functions #if false // Manage the Alarms - Called automatically on changes @@ -3870,7 +3878,7 @@ namespace CMS_CORE_Library.S7Net { // completare nuove variabili (matricola macchina, seriale PLC, firmware PLC) ConfChannelNo = 1; - Last_Static_Read = DateTime.Now; + Last_Static_Read = DateTime.Now; Cnc_name = $"{currPLC.CPU}"; // FIXME Cms_MachNumber = ""; // matricola macchina, DB604.DBB6720..6723 @@ -4043,10 +4051,45 @@ namespace CMS_CORE_Library.S7Net } } -#endregion Subordinate Private Functions + #endregion Subordinate Private Functions /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region THERMO high level data + + public CmsError PLC_RRecipeParamList(bool onlyRT, ref List currParamList) + { + // refresh dati veloci / RT + refreshMemRecipeParameterRT(); + // se richiesto NON SOLO RT faccio refresh anche dati "lenti" + if(!onlyRT) + { + refreshMemRecipeParameter(); + } + + // copio lista act in output... + currParamList = thermoParamList; + return NO_ERROR; + } + + private void refreshMemRecipeParameterRT() + { + // leggo da PLC a array di byte di appoggio... + + // converto a blocchi + + // update oggetto thermoParamList... + } + private void refreshMemRecipeParameter() + { + // leggo da PLC a array di byte di appoggio... + + // converto a blocchi + + // update oggetto thermoParamList... + } + + #endregion } @@ -4072,7 +4115,7 @@ namespace CMS_CORE_Library.S7Net internal static MEMORY_CELL RISC_ESP_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 500, 9728, 1024); internal static MEMORY_CELL RISC_OVP_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 500, 10752, 1024); internal static MEMORY_CELL RISC_ICH_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 500, 11776, 4096); - + // produzione internal static MEMORY_CELL PROCESS_STATUS = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 605, 0, 2); From a03c4bd624f16d33478a9f8127c86e5f46154b9e Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Sat, 16 May 2020 09:35:37 +0200 Subject: [PATCH 08/12] Portato in core deserializzazione ogetto recipe --- CMS_CORE_Library/Models/DataStructures.cs | 88 +++++++-------- CMS_CORE_Library/S7Net/Nc_S7Net.cs | 129 +++++++++++++++++++--- 2 files changed, 160 insertions(+), 57 deletions(-) diff --git a/CMS_CORE_Library/Models/DataStructures.cs b/CMS_CORE_Library/Models/DataStructures.cs index e2ffca3..cb6d275 100644 --- a/CMS_CORE_Library/Models/DataStructures.cs +++ b/CMS_CORE_Library/Models/DataStructures.cs @@ -526,72 +526,72 @@ namespace CMS_CORE_Library.Models public class RecipeParam { - public ushort Id { get; set; } - public int SetpointHMI { get; set; } - public int SetpointPLC { get; set; } - public double ValMax { get; set; } - public double ValMin { get; set; } - public string UnitMeasure { get; set; } - public bool Visible { get; set; } - public bool Enabled { get; set; } - public bool HasError { get; set; } - public double ValueAct { get; set; } + public short Id { get; set; } = 0; + public int SetpointHMI { get; set; } = 0; + public int SetpointPLC { get; set; } = 0; + public double ValMax { get; set; } = 0; + public double ValMin { get; set; } = 0; + public ushort UnitMeasure { get; set; } = 0; + public bool Visible { get; set; } = false; + public bool Enabled { get; set; } = false; + public bool HasError { get; set; } = false; + public double ValueAct { get; set; } = 0; } public class RecipeModule { - public ushort Id { get; set; } - public uint EstimatedDuration { get; set; } - public uint EstimatedDelay { get; set; } - public List PrecedingId { get; set; } - public uint ActualDuration { get; set; } - public uint ActualDelay { get; set; } - public bool Visible { get; set; } - public bool Running { get; set; } - public bool HasError { get; set; } + public ushort Id { get; set; } = 0; + public uint EstimatedDuration { get; set; } = 0; + public uint EstimatedDelay { get; set; } = 0; + public List PrecedingId { get; set; } = new List(); + public uint ActualDuration { get; set; } = 0; + public uint ActualDelay { get; set; } = 0; + public bool Visible { get; set; } = false; + public bool Running { get; set; } = false; + public bool HasError { get; set; } = false; } public class RecipeWarmerUp { - public ushort Id { get; set; } - public byte IdRefrector { get; set; } - public double MinCurrent { get; set; } - public byte ChStatus { get; set; } - public byte PercWork { get; set; } - public byte PercAct { get; set; } + public ushort Id { get; set; } = 0; + public byte IdRefrector { get; set; } = 0; + public double MinCurrent { get; set; } = 0; + public byte ChStatus { get; set; } = 0; + public byte PercWork { get; set; } = 0; + public byte PercAct { get; set; } = 0; } public class RecipeWarmerDown { - public ushort Id { get; set; } - public byte SetpointHMI { get; set; } + public ushort Id { get; set; } = 0; + public byte SetpointHMI { get; set; } = 0; } public class RecipeProdInfo { - public ushort NumTarget { get; set; } - public ushort NumDOne { get; set; } - public uint TimeWarm { get; set; } - public uint TimeVent { get; set; } - public uint TimeVacuum { get; set; } - public uint TimeCycleGross { get; set; } - public uint TimeCycleNet { get; set; } - public double MaterialTempEndWarm { get; set; } - public double MaterialTempEndVent { get; set; } - public double MoldTemp { get; set; } - public double VacuumReadVal { get; set; } - public double MouldEnergyOUT { get; set; } - public double MouldEnergyIN { get; set; } + public ushort NumTarget { get; set; } = 0; + public ushort NumDOne { get; set; } = 0; + public uint TimeWarm { get; set; } = 0; + public uint TimeVent { get; set; } = 0; + public uint TimeVacuum { get; set; } = 0; + public uint TimeCycleGross { get; set; } = 0; + public uint TimeCycleNet { get; set; } = 0; + public double MaterialTempEndWarm { get; set; } = 0; + public double MaterialTempEndVent { get; set; } = 0; + public double MoldTemp { get; set; } = 0; + public double VacuumReadVal { get; set; } = 0; + public double MouldEnergyOUT { get; set; } = 0; + public double MouldEnergyIN { get; set; } = 0; } public class RecipeProdCycle { - public ushort Status { get; set; } - public ushort MessageId { get; set; } - public ushort Mode { get; set; } - public uint TimeAdv { get; set; } + public ushort Status { get; set; } = 0; + public ushort MessageId { get; set; } = 0; + public ushort Mode { get; set; } = 0; + public uint TimeAdv { get; set; } = 0; } #endregion diff --git a/CMS_CORE_Library/S7Net/Nc_S7Net.cs b/CMS_CORE_Library/S7Net/Nc_S7Net.cs index aa853fd..5ad068e 100644 --- a/CMS_CORE_Library/S7Net/Nc_S7Net.cs +++ b/CMS_CORE_Library/S7Net/Nc_S7Net.cs @@ -14,7 +14,7 @@ using System.Threading; using System.Xml.Linq; using static CMS_CORE_Library.Models.DataStructures; using static CMS_CORE_Library.Nc; -using static CMS_CORE_Library.Siemens.MEMORY_ADDRESS; +using static CMS_CORE_Library.S7Net.MEMORY_ADDRESS; using static CMS_CORE_Library.ToolConfigurations; using static CMS_CORE_Library.Utils.Nc_Utils; @@ -108,8 +108,8 @@ namespace CMS_CORE_Library.S7Net private bool EnableAxes; - // parametri specifici per THERMO - private static List thermoParamList; + // Dizionario parametri specifici per THERMO + private static Dictionary thermoParamList; // connessione S7 private CpuType tipoCpu = CpuType.S71500; @@ -147,7 +147,7 @@ namespace CMS_CORE_Library.S7Net Port = RemotePort; // mesasggi generici PLC PlcMessages = new Dictionary(); - thermoParamList = new List(); + thermoParamList = new Dictionary(); } /// @@ -177,7 +177,7 @@ namespace CMS_CORE_Library.S7Net Port = RemotePort; // mesasggi generici PLC PlcMessages = new Dictionary(); - thermoParamList = new List(); + thermoParamList = new Dictionary(); } public override CmsError NC_Connect() @@ -4057,12 +4057,12 @@ namespace CMS_CORE_Library.S7Net #region THERMO high level data - public CmsError PLC_RRecipeParamList(bool onlyRT, ref List currParamList) + public CmsError PLC_RRecipeParamList(bool onlyRT, ref Dictionary currParamList) { // refresh dati veloci / RT refreshMemRecipeParameterRT(); // se richiesto NON SOLO RT faccio refresh anche dati "lenti" - if(!onlyRT) + if (!onlyRT) { refreshMemRecipeParameter(); } @@ -4072,21 +4072,124 @@ namespace CMS_CORE_Library.S7Net return NO_ERROR; } - private void refreshMemRecipeParameterRT() + protected void refreshMemRecipeParameterRT() { + List currMem = new List(); + // leggo da PLC a array di byte di appoggio... + CmsError cmsError = MEM_RWByteList(R, 0, PARAMETER_RT_DATA.MemType, PARAMETER_RT_DATA.Address, PARAMETER_RT_DATA.SubAddress, PARAMETER_RT_DATA.Size, ref currMem); - // converto a blocchi + int packSize = 8; + + // converto a blocchi di 8 byte... + byte[] memArray = currMem.ToArray(); + for (int i = 0; i < PARAMETER_RT_DATA.Size / packSize; i++) + { + PlcParamRT currParam = new PlcParamRT(memArray.Skip(i * packSize).Take(packSize).ToArray()); + // solo se ID > 0... + if (currParam.Id > 0) + { + // update oggetto thermoParamList... + if (thermoParamList.ContainsKey(currParam.Id)) + { + thermoParamList[currParam.Id].Enabled = currParam.Enabled; + thermoParamList[currParam.Id].HasError = currParam.HasError; + thermoParamList[currParam.Id].Visible = currParam.Visible; + thermoParamList[currParam.Id].ValueAct = currParam.ValueAct; + } + else + { + thermoParamList.Add(currParam.Id, new RecipeParam() { Id = currParam.Id, Enabled = currParam.Enabled, HasError = currParam.HasError, Visible = currParam.Visible, ValueAct = currParam.ValueAct }); + } + } + } - // update oggetto thermoParamList... } - private void refreshMemRecipeParameter() + protected void refreshMemRecipeParameter() { + List currMem = new List(); + // leggo da PLC a array di byte di appoggio... + CmsError cmsError = MEM_RWByteList(R, 0, PARAMETER_DATA.MemType, PARAMETER_DATA.Address, PARAMETER_DATA.SubAddress, PARAMETER_DATA.Size, ref currMem); - // converto a blocchi + int packSize = 20; - // update oggetto thermoParamList... + // converto a blocchi di 8 byte... + byte[] memArray = currMem.ToArray(); + for (int i = 0; i < PARAMETER_DATA.Size / packSize; i++) + { + PlcParam currParam = new PlcParam(memArray.Skip(i * packSize).Take(packSize).ToArray()); + // solo se ID > 0... + if (currParam.Id > 0) + { + // update oggetto thermoParamList... + if (thermoParamList.ContainsKey(currParam.Id)) + { + thermoParamList[currParam.Id].SetpointHMI = currParam.SetpointHMI; + thermoParamList[currParam.Id].SetpointPLC = currParam.SetpointPLC; + thermoParamList[currParam.Id].ValMax = currParam.ValMax; + thermoParamList[currParam.Id].ValMin = currParam.ValMin; + thermoParamList[currParam.Id].UnitMeasure = currParam.UnitMeasure; + } + else + { + thermoParamList.Add(currParam.Id, new RecipeParam() { Id = currParam.Id, SetpointHMI = currParam.SetpointHMI, SetpointPLC = currParam.SetpointPLC, ValMax = currParam.ValMax, ValMin = currParam.ValMin, UnitMeasure = currParam.UnitMeasure }); + } + } + } + } + /// + /// Oggetto Parametro RT da PLC + /// + protected class PlcParamRT + { + public short Id { get; set; } = 0; + private ushort Stato { get; set; } = 0; + public bool Visible { get; set; } + public bool Enabled { get; set; } + public bool HasError { get; set; } + public int ValueAct { get; set; } = 0; + /// + /// Deserializzazione da byte ad oggetto ParamRT + /// + /// + public PlcParamRT(byte[] rawData) + { + // converto i dati da byte grezzi ai 3 componenti... + Id = S7.Net.Types.Int.FromByteArray(rawData.Skip(0).Take(2).ToArray()); + Stato = S7.Net.Types.Word.FromByteArray(rawData.Skip(2).Take(2).ToArray()); + ValueAct = S7.Net.Types.DInt.FromByteArray(rawData.Skip(4).Take(4).ToArray()); + // calcolo bit... + Visible = (Stato & 1) == 1; + Enabled = (Stato & 2) == 2; + HasError = (Stato & 4) == 4; + } + } + /// + /// Oggetto Parametro da PLC + /// + protected class PlcParam + { + public short Id { get; set; } = 0; + public int SetpointHMI { get; set; } = 0; + public int SetpointPLC { get; set; } = 0; + public int ValMax { get; set; } = 0; + public int ValMin { get; set; } = 0; + public ushort UnitMeasure { get; set; } = 0; + /// + /// Deserializzazione da byte ad oggetto Param + /// + /// + public PlcParam(byte[] rawData) + { + // converto i dati da byte grezzi ai 3 componenti... + Id = S7.Net.Types.Int.FromByteArray(rawData.Skip(0).Take(2).ToArray()); + SetpointHMI = S7.Net.Types.DInt.FromByteArray(rawData.Skip(2).Take(4).ToArray()); + SetpointPLC = S7.Net.Types.DInt.FromByteArray(rawData.Skip(6).Take(4).ToArray()); + ValMax = S7.Net.Types.DInt.FromByteArray(rawData.Skip(10).Take(4).ToArray()); + ValMin = S7.Net.Types.DInt.FromByteArray(rawData.Skip(14).Take(4).ToArray()); + UnitMeasure = S7.Net.Types.Word.FromByteArray(rawData.Skip(18).Take(2).ToArray()); + } } #endregion From 1c3dee6468cb086d6cdc2e340f9bb601a8e2fc90 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 18 May 2020 17:25:19 +0200 Subject: [PATCH 09/12] Portato in core oggetto recipe (+override) --- CMS_CORE_Library/Demo/Nc_Demo.cs | 11 + CMS_CORE_Library/Fanuc/Nc_Fanuc.cs | 11 + CMS_CORE_Library/Nc.cs | 9 + CMS_CORE_Library/Osai/Nc_Osai.cs | 11 + CMS_CORE_Library/Properties/AssemblyInfo.cs | 4 +- CMS_CORE_Library/S7Net/Nc_S7Net.cs | 293 ++++++++++---------- CMS_CORE_Library/Siemens/Nc_Siemens.cs | 11 + 7 files changed, 206 insertions(+), 144 deletions(-) diff --git a/CMS_CORE_Library/Demo/Nc_Demo.cs b/CMS_CORE_Library/Demo/Nc_Demo.cs index e220010..2fd4714 100644 --- a/CMS_CORE_Library/Demo/Nc_Demo.cs +++ b/CMS_CORE_Library/Demo/Nc_Demo.cs @@ -1304,6 +1304,17 @@ namespace CMS_CORE_Library.Demo /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region THERMO high level data + + public override CmsError PLC_RRecipeParamList(bool onlyRT, ref Dictionary currParamList) + { + return FUNCTION_NOT_ALLOWED_ERROR; + } + + #endregion THERMO high level data + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region PROCESS (PATH) High-level data public override CmsError PROC_RStatus(ushort ProcNumber, ref PROC_STATUS Status) diff --git a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs index e9d1b2e..f732b94 100644 --- a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs +++ b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs @@ -1599,6 +1599,17 @@ namespace CMS_CORE_Library.Fanuc /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region THERMO high level data + + public override CmsError PLC_RRecipeParamList(bool onlyRT, ref Dictionary currParamList) + { + return FUNCTION_NOT_ALLOWED_ERROR; + } + + #endregion THERMO high level data + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region PROCESS (PATH) High-level data // Get process part program data diff --git a/CMS_CORE_Library/Nc.cs b/CMS_CORE_Library/Nc.cs index 2d2abb9..e33ee33 100644 --- a/CMS_CORE_Library/Nc.cs +++ b/CMS_CORE_Library/Nc.cs @@ -615,6 +615,15 @@ namespace CMS_CORE_Library /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region THERMO high level data + + public abstract CmsError PLC_RRecipeParamList(bool onlyRT, ref Dictionary currParamList); + + + #endregion THERMO high level data + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region PROCESS (PATH, CHANNEL) data (to override) /** diff --git a/CMS_CORE_Library/Osai/Nc_Osai.cs b/CMS_CORE_Library/Osai/Nc_Osai.cs index 6ab5803..ef03a2c 100644 --- a/CMS_CORE_Library/Osai/Nc_Osai.cs +++ b/CMS_CORE_Library/Osai/Nc_Osai.cs @@ -1695,6 +1695,17 @@ namespace CMS_CORE_Library.Osai /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region THERMO high level data + + public override CmsError PLC_RRecipeParamList(bool onlyRT, ref Dictionary currParamList) + { + return FUNCTION_NOT_ALLOWED_ERROR; + } + + #endregion THERMO high level data + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region PROCESS (PATH) High-level data //Get the process status diff --git a/CMS_CORE_Library/Properties/AssemblyInfo.cs b/CMS_CORE_Library/Properties/AssemblyInfo.cs index 50a077b..8a0079f 100644 --- a/CMS_CORE_Library/Properties/AssemblyInfo.cs +++ b/CMS_CORE_Library/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build // usando l'asterisco '*' come illustrato di seguito: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.1.0.0")] -[assembly: AssemblyFileVersion("1.1.0.0")] +[assembly: AssemblyVersion("1.1.2.0")] +[assembly: AssemblyFileVersion("1.1.2.0")] diff --git a/CMS_CORE_Library/S7Net/Nc_S7Net.cs b/CMS_CORE_Library/S7Net/Nc_S7Net.cs index 5ad068e..78c5ee0 100644 --- a/CMS_CORE_Library/S7Net/Nc_S7Net.cs +++ b/CMS_CORE_Library/S7Net/Nc_S7Net.cs @@ -311,8 +311,15 @@ namespace CMS_CORE_Library.S7Net { // Set Connected to FALSE and close the sessions Connected = false; - currPLC.Close(); - + if (currPLC != null) + { + try + { + currPLC.Close(); + } + catch + { } + } return NO_ERROR; } @@ -2099,6 +2106,147 @@ namespace CMS_CORE_Library.S7Net /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region THERMO high level data + + public override CmsError PLC_RRecipeParamList(bool onlyRT, ref Dictionary currParamList) + { + // refresh dati veloci / RT + refreshMemRecipeParameterRT(); + // se richiesto NON SOLO RT faccio refresh anche dati "lenti" + if (!onlyRT) + { + refreshMemRecipeParameter(); + } + + // copio lista act in output... + currParamList = thermoParamList; + return NO_ERROR; + } + + protected void refreshMemRecipeParameterRT() + { + List currMem = new List(); + + // leggo da PLC a array di byte di appoggio... + CmsError cmsError = MEM_RWByteList(R, 0, PARAMETER_RT_DATA.MemType, PARAMETER_RT_DATA.Address, PARAMETER_RT_DATA.SubAddress, PARAMETER_RT_DATA.Size, ref currMem); + + int packSize = 8; + + // converto a blocchi di 8 byte... + byte[] memArray = currMem.ToArray(); + for (int i = 0; i < PARAMETER_RT_DATA.Size / packSize; i++) + { + PlcParamRT currParam = new PlcParamRT(memArray.Skip(i * packSize).Take(packSize).ToArray()); + // solo se ID > 0... + if (currParam.Id > 0) + { + // update oggetto thermoParamList... + if (thermoParamList.ContainsKey(currParam.Id)) + { + thermoParamList[currParam.Id].Enabled = currParam.Enabled; + thermoParamList[currParam.Id].HasError = currParam.HasError; + thermoParamList[currParam.Id].Visible = currParam.Visible; + thermoParamList[currParam.Id].ValueAct = currParam.ValueAct; + } + else + { + thermoParamList.Add(currParam.Id, new RecipeParam() { Id = currParam.Id, Enabled = currParam.Enabled, HasError = currParam.HasError, Visible = currParam.Visible, ValueAct = currParam.ValueAct }); + } + } + } + + } + protected void refreshMemRecipeParameter() + { + List currMem = new List(); + + // leggo da PLC a array di byte di appoggio... + CmsError cmsError = MEM_RWByteList(R, 0, PARAMETER_DATA.MemType, PARAMETER_DATA.Address, PARAMETER_DATA.SubAddress, PARAMETER_DATA.Size, ref currMem); + + int packSize = 20; + + // converto a blocchi di 8 byte... + byte[] memArray = currMem.ToArray(); + for (int i = 0; i < PARAMETER_DATA.Size / packSize; i++) + { + PlcParam currParam = new PlcParam(memArray.Skip(i * packSize).Take(packSize).ToArray()); + // solo se ID > 0... + if (currParam.Id > 0) + { + // update oggetto thermoParamList... + if (thermoParamList.ContainsKey(currParam.Id)) + { + thermoParamList[currParam.Id].SetpointHMI = currParam.SetpointHMI; + thermoParamList[currParam.Id].SetpointPLC = currParam.SetpointPLC; + thermoParamList[currParam.Id].ValMax = currParam.ValMax; + thermoParamList[currParam.Id].ValMin = currParam.ValMin; + thermoParamList[currParam.Id].UnitMeasure = currParam.UnitMeasure; + } + else + { + thermoParamList.Add(currParam.Id, new RecipeParam() { Id = currParam.Id, SetpointHMI = currParam.SetpointHMI, SetpointPLC = currParam.SetpointPLC, ValMax = currParam.ValMax, ValMin = currParam.ValMin, UnitMeasure = currParam.UnitMeasure }); + } + } + } + } + /// + /// Oggetto Parametro RT da PLC + /// + protected class PlcParamRT + { + public short Id { get; set; } = 0; + private ushort Stato { get; set; } = 0; + public bool Visible { get; set; } + public bool Enabled { get; set; } + public bool HasError { get; set; } + public int ValueAct { get; set; } = 0; + /// + /// Deserializzazione da byte ad oggetto ParamRT + /// + /// + public PlcParamRT(byte[] rawData) + { + // converto i dati da byte grezzi ai 3 componenti... + Id = S7.Net.Types.Int.FromByteArray(rawData.Skip(0).Take(2).ToArray()); + Stato = S7.Net.Types.Word.FromByteArray(rawData.Skip(2).Take(2).ToArray()); + ValueAct = S7.Net.Types.DInt.FromByteArray(rawData.Skip(4).Take(4).ToArray()); + // calcolo bit... + Visible = (Stato & 1) == 1; + Enabled = (Stato & 2) == 2; + HasError = (Stato & 4) == 4; + } + } + /// + /// Oggetto Parametro da PLC + /// + protected class PlcParam + { + public short Id { get; set; } = 0; + public int SetpointHMI { get; set; } = 0; + public int SetpointPLC { get; set; } = 0; + public int ValMax { get; set; } = 0; + public int ValMin { get; set; } = 0; + public ushort UnitMeasure { get; set; } = 0; + /// + /// Deserializzazione da byte ad oggetto Param + /// + /// + public PlcParam(byte[] rawData) + { + // converto i dati da byte grezzi ai 3 componenti... + Id = S7.Net.Types.Int.FromByteArray(rawData.Skip(0).Take(2).ToArray()); + SetpointHMI = S7.Net.Types.DInt.FromByteArray(rawData.Skip(2).Take(4).ToArray()); + SetpointPLC = S7.Net.Types.DInt.FromByteArray(rawData.Skip(6).Take(4).ToArray()); + ValMax = S7.Net.Types.DInt.FromByteArray(rawData.Skip(10).Take(4).ToArray()); + ValMin = S7.Net.Types.DInt.FromByteArray(rawData.Skip(14).Take(4).ToArray()); + UnitMeasure = S7.Net.Types.Word.FromByteArray(rawData.Skip(18).Take(2).ToArray()); + } + } + + #endregion + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region PROCESS-AXES (PATH) High-level data public override CmsError AXES_RInterpPosition(ushort channel, ref Dictionary axes) @@ -4053,149 +4201,10 @@ namespace CMS_CORE_Library.S7Net #endregion Subordinate Private Functions - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - #region THERMO high level data - - public CmsError PLC_RRecipeParamList(bool onlyRT, ref Dictionary currParamList) - { - // refresh dati veloci / RT - refreshMemRecipeParameterRT(); - // se richiesto NON SOLO RT faccio refresh anche dati "lenti" - if (!onlyRT) - { - refreshMemRecipeParameter(); - } - - // copio lista act in output... - currParamList = thermoParamList; - return NO_ERROR; - } - - protected void refreshMemRecipeParameterRT() - { - List currMem = new List(); - - // leggo da PLC a array di byte di appoggio... - CmsError cmsError = MEM_RWByteList(R, 0, PARAMETER_RT_DATA.MemType, PARAMETER_RT_DATA.Address, PARAMETER_RT_DATA.SubAddress, PARAMETER_RT_DATA.Size, ref currMem); - - int packSize = 8; - - // converto a blocchi di 8 byte... - byte[] memArray = currMem.ToArray(); - for (int i = 0; i < PARAMETER_RT_DATA.Size / packSize; i++) - { - PlcParamRT currParam = new PlcParamRT(memArray.Skip(i * packSize).Take(packSize).ToArray()); - // solo se ID > 0... - if (currParam.Id > 0) - { - // update oggetto thermoParamList... - if (thermoParamList.ContainsKey(currParam.Id)) - { - thermoParamList[currParam.Id].Enabled = currParam.Enabled; - thermoParamList[currParam.Id].HasError = currParam.HasError; - thermoParamList[currParam.Id].Visible = currParam.Visible; - thermoParamList[currParam.Id].ValueAct = currParam.ValueAct; - } - else - { - thermoParamList.Add(currParam.Id, new RecipeParam() { Id = currParam.Id, Enabled = currParam.Enabled, HasError = currParam.HasError, Visible = currParam.Visible, ValueAct = currParam.ValueAct }); - } - } - } - - } - protected void refreshMemRecipeParameter() - { - List currMem = new List(); - - // leggo da PLC a array di byte di appoggio... - CmsError cmsError = MEM_RWByteList(R, 0, PARAMETER_DATA.MemType, PARAMETER_DATA.Address, PARAMETER_DATA.SubAddress, PARAMETER_DATA.Size, ref currMem); - - int packSize = 20; - - // converto a blocchi di 8 byte... - byte[] memArray = currMem.ToArray(); - for (int i = 0; i < PARAMETER_DATA.Size / packSize; i++) - { - PlcParam currParam = new PlcParam(memArray.Skip(i * packSize).Take(packSize).ToArray()); - // solo se ID > 0... - if (currParam.Id > 0) - { - // update oggetto thermoParamList... - if (thermoParamList.ContainsKey(currParam.Id)) - { - thermoParamList[currParam.Id].SetpointHMI = currParam.SetpointHMI; - thermoParamList[currParam.Id].SetpointPLC = currParam.SetpointPLC; - thermoParamList[currParam.Id].ValMax = currParam.ValMax; - thermoParamList[currParam.Id].ValMin = currParam.ValMin; - thermoParamList[currParam.Id].UnitMeasure = currParam.UnitMeasure; - } - else - { - thermoParamList.Add(currParam.Id, new RecipeParam() { Id = currParam.Id, SetpointHMI = currParam.SetpointHMI, SetpointPLC = currParam.SetpointPLC, ValMax = currParam.ValMax, ValMin = currParam.ValMin, UnitMeasure = currParam.UnitMeasure }); - } - } - } - } - /// - /// Oggetto Parametro RT da PLC - /// - protected class PlcParamRT - { - public short Id { get; set; } = 0; - private ushort Stato { get; set; } = 0; - public bool Visible { get; set; } - public bool Enabled { get; set; } - public bool HasError { get; set; } - public int ValueAct { get; set; } = 0; - /// - /// Deserializzazione da byte ad oggetto ParamRT - /// - /// - public PlcParamRT(byte[] rawData) - { - // converto i dati da byte grezzi ai 3 componenti... - Id = S7.Net.Types.Int.FromByteArray(rawData.Skip(0).Take(2).ToArray()); - Stato = S7.Net.Types.Word.FromByteArray(rawData.Skip(2).Take(2).ToArray()); - ValueAct = S7.Net.Types.DInt.FromByteArray(rawData.Skip(4).Take(4).ToArray()); - // calcolo bit... - Visible = (Stato & 1) == 1; - Enabled = (Stato & 2) == 2; - HasError = (Stato & 4) == 4; - } - } - /// - /// Oggetto Parametro da PLC - /// - protected class PlcParam - { - public short Id { get; set; } = 0; - public int SetpointHMI { get; set; } = 0; - public int SetpointPLC { get; set; } = 0; - public int ValMax { get; set; } = 0; - public int ValMin { get; set; } = 0; - public ushort UnitMeasure { get; set; } = 0; - /// - /// Deserializzazione da byte ad oggetto Param - /// - /// - public PlcParam(byte[] rawData) - { - // converto i dati da byte grezzi ai 3 componenti... - Id = S7.Net.Types.Int.FromByteArray(rawData.Skip(0).Take(2).ToArray()); - SetpointHMI = S7.Net.Types.DInt.FromByteArray(rawData.Skip(2).Take(4).ToArray()); - SetpointPLC = S7.Net.Types.DInt.FromByteArray(rawData.Skip(6).Take(4).ToArray()); - ValMax = S7.Net.Types.DInt.FromByteArray(rawData.Skip(10).Take(4).ToArray()); - ValMin = S7.Net.Types.DInt.FromByteArray(rawData.Skip(14).Take(4).ToArray()); - UnitMeasure = S7.Net.Types.Word.FromByteArray(rawData.Skip(18).Take(2).ToArray()); - } - } - - #endregion } + internal static class MEMORY_ADDRESS { // Tabella DB principale diff --git a/CMS_CORE_Library/Siemens/Nc_Siemens.cs b/CMS_CORE_Library/Siemens/Nc_Siemens.cs index ea0d2ac..72e977e 100644 --- a/CMS_CORE_Library/Siemens/Nc_Siemens.cs +++ b/CMS_CORE_Library/Siemens/Nc_Siemens.cs @@ -2113,6 +2113,17 @@ namespace CMS_CORE_Library.Siemens /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region THERMO high level data + + public override CmsError PLC_RRecipeParamList(bool onlyRT, ref Dictionary currParamList) + { + return FUNCTION_NOT_ALLOWED_ERROR; + } + + #endregion THERMO high level data + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + #region PROCESS (PATH) High-level data // Get the process Mode From 9d1cddcebf36367e156cb81820dae24291536a10 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 18 May 2020 17:55:23 +0200 Subject: [PATCH 10/12] refresh standard methods after debug --- CMS_CORE_Library/CMS_CORE_Library.csproj | 2 +- CMS_CORE_Library/S7Net/Nc_S7Net.cs | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CMS_CORE_Library/CMS_CORE_Library.csproj b/CMS_CORE_Library/CMS_CORE_Library.csproj index 389be1e..f498d1d 100644 --- a/CMS_CORE_Library/CMS_CORE_Library.csproj +++ b/CMS_CORE_Library/CMS_CORE_Library.csproj @@ -18,7 +18,7 @@ full false bin\Debug\ - DEBUG;TRACE + TRACE;DEBUG;FS30D,WIN32 prompt 4 diff --git a/CMS_CORE_Library/S7Net/Nc_S7Net.cs b/CMS_CORE_Library/S7Net/Nc_S7Net.cs index 78c5ee0..0fcbe72 100644 --- a/CMS_CORE_Library/S7Net/Nc_S7Net.cs +++ b/CMS_CORE_Library/S7Net/Nc_S7Net.cs @@ -60,6 +60,7 @@ namespace CMS_CORE_Library.S7Net // Global Variables private static DateTime Last_Static_Read; + private byte S7Language; private static string Cnc_name; private static string Cnc_SftVersion; private static string Cnc_SeriesNum; @@ -534,7 +535,14 @@ namespace CMS_CORE_Library.S7Net // Get the NC Language public override CmsError NC_RLanguage(ref CultureInfo Language) { - return FUNCTION_NOT_ALLOWED_ERROR; + // Read static data + CmsError cmsError = ReadStaticNCData(); + if (cmsError.IsError()) + return cmsError; + + Language = ConvertToSTEPLanguage(S7Language); + + return NO_ERROR; } // Set the NC Language @@ -585,7 +593,8 @@ namespace CMS_CORE_Library.S7Net // Get the Date-Time of the NC public override CmsError NC_RDateTime(ref DateTime ActualTime) { - return FUNCTION_NOT_ALLOWED_ERROR; + ActualTime = DateTime.Now; + return NO_ERROR; } // Check if the NC is in running state @@ -4025,11 +4034,12 @@ namespace CMS_CORE_Library.S7Net try { // completare nuove variabili (matricola macchina, seriale PLC, firmware PLC) + S7Language = 0; ConfChannelNo = 1; Last_Static_Read = DateTime.Now; Cnc_name = $"{currPLC.CPU}"; // FIXME - Cms_MachNumber = ""; // matricola macchina, DB604.DBB6720..6723 + Cms_MachNumber = "0000"; // matricola macchina, DB604.DBB6720..6723 Cnc_SftVersion = "SMC000"; // versione SW del firmware PLC/CNC | DB604.DBB6724..6745 Cnc_SeriesNum = "SMC111"; // seriale PLC/CNC | DB604.DBB6746..6763 PlcRirm_SeriesNum = "V.0.0.0"; // seriale PLC/CNC | DB604.DBB6764..6767 From fc68a938be48d8beb2c401e6afc3b0cbf61e4072 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 18 May 2020 19:13:32 +0200 Subject: [PATCH 11/12] ok primo giro con Thermo active x CORE --- CMS_CORE_Library/Nc.cs | 2 +- CMS_CORE_Library/S7Net/Nc_S7Net.cs | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CMS_CORE_Library/Nc.cs b/CMS_CORE_Library/Nc.cs index e33ee33..11093e9 100644 --- a/CMS_CORE_Library/Nc.cs +++ b/CMS_CORE_Library/Nc.cs @@ -1986,7 +1986,7 @@ namespace CMS_CORE_Library /////////////////////////////////////////////////////////////////// // Demo memory type /**Demo default memory **/ - Demo = 1000 + Demo = 10000 }; // NC Memory Type Name diff --git a/CMS_CORE_Library/S7Net/Nc_S7Net.cs b/CMS_CORE_Library/S7Net/Nc_S7Net.cs index 0fcbe72..29503d5 100644 --- a/CMS_CORE_Library/S7Net/Nc_S7Net.cs +++ b/CMS_CORE_Library/S7Net/Nc_S7Net.cs @@ -91,7 +91,7 @@ namespace CMS_CORE_Library.S7Net private static DataSvc SelectedProcessSvc; #endif - private static ushort SelectedProcess = 0; + private static ushort SelectedProcess = 1; #if false private static Dictionary MachineAxesPosition = new Dictionary(); @@ -916,7 +916,7 @@ namespace CMS_CORE_Library.S7Net softKeyStatusMemory.MemType, softKeyStatusMemory.Address, softKeyStatusMemory.SubAddress, - memorySizeToRead / 4, + memorySizeToRead / 1, // 4, ref readValues); if (cmsError.IsError()) @@ -2702,8 +2702,10 @@ namespace CMS_CORE_Library.S7Net CmsError cmsError = MEM_RWIntegerList(bWrite, Process, MemType, MemTable, MemIndex, 1, ref ListValue); if (cmsError.IsError()) return cmsError; - - Value = ListValue.First(); + if (ListValue.Count > 0) + { + Value = ListValue.First(); + } return NO_ERROR; } @@ -4254,7 +4256,7 @@ namespace CMS_CORE_Library.S7Net internal static MEMORY_CELL FUNCTION_ACCESS = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 6, 8); - internal static MEMORY_CELL PRE_POST_POWER_ON = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 2574, 2); + internal static MEMORY_CELL PRE_POST_POWER_ON = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 6542, 1); internal static MEMORY_CELL PRE_POST_POWER_ON_CLICKABLE = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 2576, 2); internal static MEMORY_CELL PRE_POST_POWER_ON_ACK = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 2578, 2); internal static MEMORY_CELL PRE_POST_POWER_ON_CLICKED = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 2580, 2); @@ -4274,10 +4276,10 @@ namespace CMS_CORE_Library.S7Net internal static MEMORY_CELL NC_SOFT_KEYS_ACK = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 2618, 4); internal static MEMORY_CELL NC_SOFT_KEYS_CLICKED = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 2622, 4); - internal static MEMORY_CELL USER_SOFTKEYS_VALUE = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 2628, 16); - internal static MEMORY_CELL USER_SOFTKEYS_CLICKABLE = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 2644, 16); - internal static MEMORY_CELL USER_SOFT_KEYS_ACK = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 2660, 16); - internal static MEMORY_CELL USER_SOFT_KEYS_CLICKED = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 2676, 16); + internal static MEMORY_CELL USER_SOFTKEYS_VALUE = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 6552, 16); + internal static MEMORY_CELL USER_SOFTKEYS_CLICKABLE = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 6568, 16); + internal static MEMORY_CELL USER_SOFT_KEYS_ACK = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 6584, 16); + internal static MEMORY_CELL USER_SOFT_KEYS_CLICKED = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 6616, 16); internal static MEMORY_CELL ALARMS_STATUS = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 14, 128); internal static MEMORY_CELL ALARMS_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 142, 1024); From 92a616c78a8d69de1a1c04267ef1cfdd9097c12f Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 19 May 2020 16:22:54 +0200 Subject: [PATCH 12/12] Update core library x nuovo NcThermo --- CMS_CORE_Application/Form1.cs | 5 + CMS_CORE_Library/CMS_CORE_Library.csproj | 2 + CMS_CORE_Library/Demo/Nc_Demo.cs | 11 - CMS_CORE_Library/Fanuc/Nc_Fanuc.cs | 11 - CMS_CORE_Library/Models/CmsError.cs | 3 +- CMS_CORE_Library/Models/DataStructures.cs | 1 + CMS_CORE_Library/Models/ThermoModels.cs | 22 + CMS_CORE_Library/Nc.cs | 9 - CMS_CORE_Library/NcThermo.cs | 1832 +++++++++++++++++++++ CMS_CORE_Library/Osai/Nc_Osai.cs | 11 - CMS_CORE_Library/S7Net/Nc_S7Net.cs | 221 ++- CMS_CORE_Library/Siemens/Nc_Siemens.cs | 11 - 12 files changed, 1973 insertions(+), 166 deletions(-) create mode 100644 CMS_CORE_Library/Models/ThermoModels.cs create mode 100644 CMS_CORE_Library/NcThermo.cs diff --git a/CMS_CORE_Application/Form1.cs b/CMS_CORE_Application/Form1.cs index 80836d9..7d107da 100644 --- a/CMS_CORE_Application/Form1.cs +++ b/CMS_CORE_Application/Form1.cs @@ -217,6 +217,11 @@ namespace CMS_CORE_Application return new Nc_Osai(NCIp, NCPort, 50000); if (NCType == "Fanuc") return new Nc_Fanuc(NCIp, NCPort, 2000); + + return null; + } + private NcThermo SetNcThermoByType() + { if (NCType == "S7Net") return new Nc_S7Net(NCIp, NCPort, 500); diff --git a/CMS_CORE_Library/CMS_CORE_Library.csproj b/CMS_CORE_Library/CMS_CORE_Library.csproj index f498d1d..a79a51c 100644 --- a/CMS_CORE_Library/CMS_CORE_Library.csproj +++ b/CMS_CORE_Library/CMS_CORE_Library.csproj @@ -151,7 +151,9 @@ + + diff --git a/CMS_CORE_Library/Demo/Nc_Demo.cs b/CMS_CORE_Library/Demo/Nc_Demo.cs index 2fd4714..e220010 100644 --- a/CMS_CORE_Library/Demo/Nc_Demo.cs +++ b/CMS_CORE_Library/Demo/Nc_Demo.cs @@ -1304,17 +1304,6 @@ namespace CMS_CORE_Library.Demo /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - #region THERMO high level data - - public override CmsError PLC_RRecipeParamList(bool onlyRT, ref Dictionary currParamList) - { - return FUNCTION_NOT_ALLOWED_ERROR; - } - - #endregion THERMO high level data - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - #region PROCESS (PATH) High-level data public override CmsError PROC_RStatus(ushort ProcNumber, ref PROC_STATUS Status) diff --git a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs index f732b94..e9d1b2e 100644 --- a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs +++ b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs @@ -1599,17 +1599,6 @@ namespace CMS_CORE_Library.Fanuc /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - #region THERMO high level data - - public override CmsError PLC_RRecipeParamList(bool onlyRT, ref Dictionary currParamList) - { - return FUNCTION_NOT_ALLOWED_ERROR; - } - - #endregion THERMO high level data - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - #region PROCESS (PATH) High-level data // Get process part program data diff --git a/CMS_CORE_Library/Models/CmsError.cs b/CMS_CORE_Library/Models/CmsError.cs index 290bea2..9cda4bc 100644 --- a/CMS_CORE_Library/Models/CmsError.cs +++ b/CMS_CORE_Library/Models/CmsError.cs @@ -73,6 +73,7 @@ namespace CMS_CORE_Library.Models OPTION_NOT_CONSISTENT = 28, WRONG_CMS_PP = 29, SIEMENS_TOOL_TABLE_ERROR = 30, - PLC_IP_NOT_FOUND = 31 + PLC_IP_NOT_FOUND = 31, + PLC_MEM_CONF_ERROR = 32 } } \ No newline at end of file diff --git a/CMS_CORE_Library/Models/DataStructures.cs b/CMS_CORE_Library/Models/DataStructures.cs index cb6d275..d9d5607 100644 --- a/CMS_CORE_Library/Models/DataStructures.cs +++ b/CMS_CORE_Library/Models/DataStructures.cs @@ -199,6 +199,7 @@ namespace CMS_CORE_Library.Models public static CmsError OPTION_NOT_CONSISTENT_ERROR = new CmsError(CMS_ERROR_CODES.OPTION_NOT_CONSISTENT, "error_option_not_consistent"); public static CmsError WRONG_CMS_PP_ERROR = new CmsError(CMS_ERROR_CODES.WRONG_CMS_PP, "error_wrong_custom_part_program"); public static CmsError SIEMENS_TOOL_TABLE_ERROR = new CmsError(CMS_ERROR_CODES.SIEMENS_TOOL_TABLE_ERROR, "error_siemens_tool_table_error"); + public static CmsError PLC_MEM_CONF_ERROR = new CmsError(CMS_ERROR_CODES.PLC_MEM_CONF_ERROR, "error_plc_mem_conf_not_found"); #endregion Cms Errors Codes diff --git a/CMS_CORE_Library/Models/ThermoModels.cs b/CMS_CORE_Library/Models/ThermoModels.cs new file mode 100644 index 0000000..0946cd2 --- /dev/null +++ b/CMS_CORE_Library/Models/ThermoModels.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CMS_CORE_Library.Models +{ + public class ThermoModels + { + /// + /// Represents thermo gauge data + /// + public class GaugeModel + { + public uint TimeAdv { get; set; } = 0; + public int Power { get; set; } = 0; + public int Vacuum { get; set; } = 0; + public int Air { get; set; } = 0; + } + } +} diff --git a/CMS_CORE_Library/Nc.cs b/CMS_CORE_Library/Nc.cs index 11093e9..a25b878 100644 --- a/CMS_CORE_Library/Nc.cs +++ b/CMS_CORE_Library/Nc.cs @@ -615,15 +615,6 @@ namespace CMS_CORE_Library /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - #region THERMO high level data - - public abstract CmsError PLC_RRecipeParamList(bool onlyRT, ref Dictionary currParamList); - - - #endregion THERMO high level data - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - #region PROCESS (PATH, CHANNEL) data (to override) /** diff --git a/CMS_CORE_Library/NcThermo.cs b/CMS_CORE_Library/NcThermo.cs new file mode 100644 index 0000000..c5449fe --- /dev/null +++ b/CMS_CORE_Library/NcThermo.cs @@ -0,0 +1,1832 @@ +using CMS_CORE_Library.Models; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Reflection; +using static CMS_CORE_Library.Models.DataStructures; +using static CMS_CORE_Library.Models.ThermoModels; +using static CMS_CORE_Library.Nc; +using static CMS_CORE_Library.Nc.MEMORY_TYPE; + +namespace CMS_CORE_Library +{ + public abstract partial class NcThermo + { + //Private Global Variables + internal bool Connected; + + internal string Ip; + internal ushort Port; + internal bool UseProxy; + internal string LibName = "CMS_CORE_Library.dll"; + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + #region LIB Methods + + /** + * + * Get the NC IP-Address + * + * Compatibility: Fanuc | Osai | Demo + * + * + * */ + + public string LIB_GetIpAddress() + { + return Ip; + } + + /** + * + * Set the NC IP-Address + * + * Compatibility: Fanuc | Osai | Demo + * + * + * */ + + public void LIB_SetIpAddress(string ip) + { + Ip = ip; + } + + /** + * + * Get Nc Port + * + * Compatibility: Fanuc | Osai | Demo + * + * + * */ + + public ushort LIB_GetPort() + { + return Port; + } + + /** + * + * Set Nc Port + * + * Compatibility: Fanuc | Osai | Demo + * + * + * */ + + public void LIB_SetPort(ushort port) + { + Port = port; + } + + /** + * + * Get Library Version + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * */ + + public string LIB_GetLibraryVersion() + { + return FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion.ToString(); + } + + #endregion LIB Methods + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + #region NC High-level data (to override) + + /** + * + * Connect the NC + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * Returns an error when an internal or a library error occours + * + * */ + + public abstract CmsError NC_Connect(); + + /** + * + * Disconnect the NC + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * Returns an error when an internal or a library error occours + * + * */ + + public abstract CmsError NC_Disconnect(); + + /** + * + * Read Nc Status + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * */ + + public bool NC_IsConnected() + { + return Connected; + } + + /** + * + * Read actual time of the NC-Software (sometimes it can be different from NC-Operative-System) + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Reference of a DateTime Variable where data will be saved + * */ + + public abstract CmsError NC_RDateTime(ref DateTime ActualTime); + + /** + * + * Read Vendor NC Serial number + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Reference of a String Variable where data will be saved + * */ + + public abstract CmsError NC_RSerialNumber(ref string SN); + + /** + * + * Read Model name of the NC + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Reference of a String Variable where data will be saved + * */ + + public abstract CmsError NC_RModelName(ref string ModelName); + + /** + * + * Read Software Version of the Nc + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Reference of a String Variable where data will be saved + * */ + + public abstract CmsError NC_RSoftwareVersion(ref string SWV); + + /** + * + * Read CMS Serial number of the Machine + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Reference of a String Variable where data will be saved + * */ + + public abstract CmsError NC_RMachineNumber(bool hasLetters, ref string MachNumber); + + /** + * + * Read number of configured Processes/Paths + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Reference of a ushort Variable where data will be saved + * */ + + public abstract CmsError NC_RProcessesNum(ref ushort ProcNumber); + + /** + * + * Read the configured language of the NC + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Reference of a CultureInfo Variable where data will be saved + * */ + + public abstract CmsError NC_RLanguage(ref CultureInfo Language); + + /** + * + * Write the configured language of the NC + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * CultureInfo Variable with the new Language + * */ + + public abstract CmsError NC_WLanguage(CultureInfo Language); + + /** + * + * Read active alarms of the NC (Nc-Process indipendent). For OSAI Nc the list can contain only one Message + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Process to execute the action + * Reference of a List of String Variables where data will be saved + * */ + + public abstract CmsError NC_RActiveAlarms(ref List alarms); + + /** + * + * Check if the NC is in running state + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Reference to boolean where running state will be saved + * */ + + public abstract CmsError NC_RIsRunning(ref bool running); + + public abstract CmsError NC_GetTranslatedPlcMessages(string language, ref Dictionary messages); + + public abstract CmsError NC_GetAvailableLanguages(ref ICollection languages); + + /** + * + * Set the screen page visible of the NC + * + * Compatibility: Fanuc | Siemens + * + * + * Returns an error when an internal or a library error occours + * change the screen view in HMI application + * */ + + public abstract CmsError NC_SetScreenVisible(SCREEN_PAGE screen); + + // Get NC unit of measure + public abstract CmsError NC_RUnitOfMeasure(ref string unitOfMeasure); + + #endregion NC High-level data (to override) + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + #region NC Low-level data (to override) + + /** + * Read Boolean Parameter Machine (Not compatible for Axis Parameter (Multiple values in a parameter) + * + * Compatibility: Fanuc + * + * + * Returns an error when an internal or a library error occours + * Index of the parameter + * Set the Bit to Read. (0..7) + * Reference of a variable with Param values + * */ + + public abstract CmsError NC_RParam(short Index, short Bit, ref bool Value); + + /** + * Read Byte Parameter Machine (Not compatible for Axis Parameter (Multiple values in a parameter) + * + * Compatibility: Fanuc + * + * + * Returns an error when an internal or a library error occours + * Index of the parameter + * Reference of a variable with Param values + * */ + + public abstract CmsError NC_RParam(short Index, ref byte Value); + + /** + * Read 2 Byte (Short) Parameter Machine (Not compatible for Axis Parameter (Multiple values in a parameter) + * + * Compatibility: Fanuc + * + * + * Returns an error when an internal or a library error occours + * Index of the parameter + * Reference of a variable with Param values + * */ + + public abstract CmsError NC_RParam(short Index, ref short Value); + + /** + * Read 4 Byte (Integer) Parameter Machine (Not compatible for Axis Parameter (Multiple values in a parameter) + * + * Compatibility: Fanuc + * + * + * Returns an error when an internal or a library error occours + * Index of the parameter + * Reference of a variable with Param values + * */ + + public abstract CmsError NC_RParam(short Index, ref int Value); + + /** + * Read Real Parameter Machine (Not compatible for Axis Parameter (Multiple values in a parameter) + * + * Compatibility: Fanuc + * + * + * Returns an error when an internal or a library error occours + * Index of the parameter + * Reference of a variable with Param values + * */ + + public abstract CmsError NC_RParam(short Index, ref double Value); + + public abstract CmsError NC_WMDICommand(int processId, string mdiString); + + #endregion NC Low-level data (to override) + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + #region PLC High-level data (to override) + + public abstract CmsError PLC_RWManageWatchdog(); + + /** + * + * Read PMC active Messages + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Reference of a List of String Variables where data will be saved + * */ + + public abstract CmsError PLC_RActiveMessages(ref List Alarms); + + /** + * + * Start refresh message procedure + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Alarm id to refresh + * * */ + + public abstract CmsError PLC_WRefreshMessage(uint id); + + public abstract CmsError PLC_WRefreshAllMessages(); + + /** + * + * Start restore message procedure + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Alarm id to restore + * + * */ + + public abstract CmsError PLC_WRestoreMessage(uint id); + + /** + * + * Read the status of the Power on data ( Pre-Power-On / Post-Power-On ) + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * Returns an error when an internal or a library error occours + * + * Reference to the structure where the power on data will be saved + **/ + + public abstract CmsError PLC_RPowerOnData(ref PreAndPostPowerOnModel powerOnModel); + + /** + * + * Write PowerOn data and status ( Pre-Power-On / Post-Power-On ) + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * Returns an error when an internal or a library error occours + * + * Id of the edited power on data + * Reference to the value of the power on data + **/ + + public abstract CmsError PLC_WPowerOnData(uint id, bool value); + + /** + * + * Read the status of the UI functionality from PLC + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * Returns an error when an internal or a library error occours + * + **/ + + public abstract CmsError PLC_RFunctionAccess(ref List functions); + + /** + * + * Read axes reset procedure data from PLC + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * Returns an error when an internal or a library error occours + * Reference to the axes reset procedure data + * + **/ + + public abstract CmsError PLC_RAxesResetData(ref AxisResetDataModel axisResetData); + + /** + * + * Read machine counters value from PLC + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * Returns an error when an internal or a library error occours + * Reference to the counters data + * + **/ + + public abstract CmsError PLC_RMachineCounters(ref List counters); + + /** + * + * Reset single machine counter + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * Returns an error when an internal or a library error occours + * number of counter to be zeroed + * + **/ + + public abstract CmsError PLC_WResetMachineCounters(uint counter); + + /** + * + * Read nc softkeys values from PLC + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * Returns an error when an internal or a library error occours + * Reference to the nc softkey data + * + **/ + + public abstract CmsError PLC_RNcSoftKeys(ref List ncSoftKeys); + + /** + * + * Read user softkeys values from PLC + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * Returns an error when an internal or a library error occours + * Reference to the softkey data + * + **/ + + public abstract CmsError PLC_RUserSoftKeys(ref List softKeys); + + /** + * + * Write Nc softkey interaction into PLC + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * Returns an when an internal or a library error occours + * Nc softkey id + * + **/ + + public abstract CmsError PLC_WNcSoftKey(uint id); + + /** + * + * Write user softkey interaction into PLC + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * Returns an error when an internal or a library error occours + * User softkey id + * + **/ + + public abstract CmsError PLC_WUserSoftKey(uint id); + + /** + * + * Read heads data from PLC + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * Returns an error when an internal or a library error occours + * Recerence to the heads data + * Number of heads data that are read + * + **/ + + public abstract CmsError PLC_RHeadsData(List heads, int number); + + /** + * + * Write head override sign into PLC + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * Returns an error when an internal or a library error occours + * Head id + * Type of increment of the override + * + **/ + + public abstract CmsError PLC_WHeadOverride(uint id, HEAD_OVERRIDE_SIGN sign); + + public abstract CmsError PLC_ROperatorInputIsNeeded(ref List value); + + public abstract CmsError PLC_WOperatorInputResponse(int process, double responseVal); + + public abstract CmsError PLC_RM154Data(ref List value, ref bool MTCCmd); + + public abstract CmsError PLC_W154ManageAck(int processId); + + public abstract CmsError PLC_RM156Data(ref List value); + + public abstract CmsError PLC_WM156Response(int process, double responseVal); + + public abstract CmsError PLC_RScadaValue(string memIndex, SCADA_MEM_TYPE memType, ref object value); + + public abstract CmsError PLC_WScadaValue(string memIndex, SCADA_MEM_TYPE memType, object value); + + public abstract CmsError PLC_RScadaSiemens(ref List objects); + + public abstract CmsError PLC_RWorkedTimeHead(int head, ref uint time); + + public abstract CmsError PLC_WResetWorkedTimeHead(int head); + + public abstract CmsError PLC_RWorkedTimeMachine(ref uint time); + + public abstract CmsError PLC_WResetWorkedTimeMachine(uint time); + + public abstract CmsError PLC_RCandy(ref long value); + + public abstract CmsError PLC_WCandy(long value); + + public abstract CmsError PLC_RExpiredCandy(ref bool value); + + public abstract CmsError PLC_WExpiredCandy(bool value); + + public abstract CmsError PLC_RActiveClient(ref int clientId); + + public abstract CmsError PLC_RToolMovement(ref MovementBetweenMagazinesModel toolMovement); + + public abstract CmsError PLC_WTerminateMovementProcedure(MOVEMENT_RESPONSE resp); + + /// + /// + /// Read power gauge data + /// + /// Compatibility: S7Net + /// + /// Returns an error when an internal or a library error occours + /// + /// Reference to the value of the gauge data + public abstract CmsError PLC_RGaugeData(ref GaugeModel gaugeData); + + #endregion PLC High-level data (to override) + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + #region THERMO high level data + + public abstract CmsError PLC_RRecipeParamList(bool onlyRT, ref Dictionary currParamList); + + + #endregion THERMO high level data + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + #region PROCESS (PATH, CHANNEL) data (to override) + + /** + * + * Read the actual status of the Process "ProcNumber" + * See for information about the PROC_Status type + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Process number which the data refer + * Reference of a PROC_Status Variable where data will be saved + * */ + + public abstract CmsError PROC_RStatus(ushort ProcNumber, ref PROC_STATUS Status); + + /** + * + * Read the selected Mode Process "ProcNumber" + * See for information about the PROC_Status type + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Process number which the data refer + * Reference of a PROC_Mode Variable where data will be saved + * */ + + public abstract CmsError PROC_RMode(ushort ProcNumber, ref PROC_MODE Mode); + + /** + * + * Read active alarms of the process "ProcNumber". For OSAI Nc the list can contain only one Message + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Process number which the data refer + * Reference of a List of String Variables where data will be saved + * */ + + public abstract CmsError PROC_RActiveAlarms(ushort procNumber, ref List alarms); + + /** + * + * Read actual & Next Lines of active PP + * + * Compatibility: Fanuc | Osai | Siemens + * + * + * Returns an error when an internal or a library error occours + * Process number which the data refer + * Reference of a List of String Variables where data will be saved + * */ + + public abstract CmsError PROC_RPPLines(ushort procNumber, ref List Lines); + + /** + * + * Read active PP Name + * + * Compatibility: Fanuc | Osai | Siemens + * + * + * Returns an error when an internal or a library error occours + * Process number which the data refer + * Reference of a String Variables where data will be saved + * */ + + public abstract CmsError PROC_RSelectedPPName(ushort procNumber, ref string Name); + + /** + * + * Read active PP and generic data + * + * Compatibility: Fanuc | Osai | Siemens + * + * Process number which the data refer + * Reference to part program data structure + * + **/ + + public abstract CmsError PROC_RStatusAndData(ushort procNumber, ref ProcessDataModel processData); + + /** + * + * Read selected process + * + * Compatibility: Fanuc | Osai | Siemens + * + * Reference to the process number selected + * + **/ + + public abstract CmsError PROC_RSelectedProcess(ref ushort procNumber); + + /** + * + * Change the selected process + * + * Compatibility: Fanuc | Osai | Siemens + * + * New selected process number + * + **/ + + public abstract CmsError PROC_WSelectProcess(ushort procNumber); + + /** + * + * Read additional data of the process + * + * Compatibility: Fanuc | Osai | Siemens + * + * Id of the process + * + **/ + + public abstract CmsError PROC_RSelectedProcessData(int processId, ref SelectedProcessData processData); + + /** + * + * Start assisted tooling + * + * Compatibility: Fanuc | Osai | Siemens + * + * + **/ + + public abstract CmsError PLC_WAssistedToolingCmd(ushort toolId, ushort familyId, ushort shankId, ushort magazineId, ushort positionId, ASSISTED_TOOLING_ACTION action); + + /** + * + * Read the status of the assisted tooling procedure + * + * Compatibility: Fanuc | Osai | Siemens + * + * + **/ + + public abstract CmsError PLC_RAssistedToolingData(ref AssistedToolingModel data); + + /** + * + * Manage ack-strobe in order to terminate the assisted tooling procedure + * + * Compatibility: Fanuc | Osai | Siemens + * + * + **/ + + public abstract CmsError PLC_WTerminateAssistedToolingProcedure(); + + #endregion PROCESS (PATH, CHANNEL) data (to override) + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + #region AXES data (to override) + + /** + * + * Read the Interpolated position of all axes in Process "ProcNumber" + * + * Compatibility: Fanuc | Osai | Demo + * + * + * Returns an error when an internal or a library error occours + * Process to execute the action + * Reference of Dictionary "Key,Value" with: Key: Axis Name, Value: Position + * */ + + public abstract CmsError AXES_RInterpPosition(ushort ProcNumber, ref Dictionary Axes); + + /** + * + * Read the Programmed position of all axes in Process "ProcNumber". + * For Fanuc-Nc there's not "Programmed position" variables. Si it is calculated from Machine-Pos and Distance-to-go + * + * Compatibility: Fanuc | Osai | Demo + * + * + * Returns an error when an internal or a library error occours + * Process to execute the action + * Reference of Dictionary "Key,Value" with: Key: Axis Name, Value: Position + * */ + + public abstract CmsError AXES_RProgrPosition(ushort ProcNumber, ref Dictionary Axes); + + /** + * + * Read the Machine position of all axes in Process "ProcNumber" + * + * Compatibility: Fanuc | Osai | Demo + * + * + * Returns an error when an internal or a library error occours + * Process to execute the action + * Reference of Dictionary "Key,Value" with: Key: Axis Name, Value: Position + * */ + + public abstract CmsError AXES_RMachinePosition(ushort ProcNumber, ref Dictionary Axes); + + /** + * + * Read the Following-Error of all axes in Process "ProcNumber" + * + * Compatibility: Osai | Demo + * + * + * Returns an error when an internal or a library error occours + * Process to execute the action + * Reference of Dictionary "Key,Value" with: Key: Axis Name, Value: Position + * */ + + public abstract CmsError AXES_RFollowingError(ushort ProcNumber, ref Dictionary Axes); + + /** + * + * Read the Distance-to-go of all axes in Process "ProcNumber" + * + * Compatibility: Fanuc | Osai | Siemens + * + * + * Returns an error when an internal or a library error occours + * Process to execute the action + * Reference of Dictionary "Key,Value" with: Key: Axis Name, Value: Position + * */ + + public abstract CmsError AXES_RDistanceToGo(ushort ProcNumber, ref Dictionary Axes); + + /** + * + * Read the names of the axes in the process + * + * Compatibility: Fanuc | Osai | Siemens + * + * + * Returns an error when an internal or a library error occours + * Process to execute the action + * List of data + * */ + + public abstract CmsError AXES_RAxesNames(ushort process, ref List axesData); + + /** + * + * Read the selected axes in the selected process + * + * Compatibility: Fanuc | Osai | Siemens + * + * + * Returns an error when an internal or a library error occours + * Id of the selected axis + * */ + + public abstract CmsError AXES_RSelectedAxis(ref byte axisId); + + /** + * + * Selected one axis on the selected process + * + * Compatibility: Fanuc | Osai | Siemens + * + * + * Returns an error when an internal or a library error occours + * Id of the axis to be selected + * */ + + public abstract CmsError AXES_WSelectAxis(byte axisId); + + public abstract CmsError AXES_ROrigin(int numberOfAxes); + + #endregion AXES data (to override) + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + #region MEMORY Low-level function: single valiable in memory (to override) + + /** + * Read/Write Boolean variable from/into NC Memory Area (including Siemens Nc) + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Set True to Write-operation (Also Allowed /) + * Process to perform operation (If the area is process-indipendent use 0 or ) + * Nc Memory Area. See + * Siemens Memory Table (Used only in Siemens-Nc) + * Starting Index of Memory Area + * Set the Bit to Read-Write. (0..7) + * Reference to variable to read/Write + * */ + + public abstract CmsError MEM_RWBoolean(bool bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, int MemBit, ref bool Value); + + /** + * Read/Write Byte variable from/into NC Memory Area (including Siemens Nc) + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Set True to Write-operation (Also Allowed /) + * Process to perform operation (If the area is process-indipendent use 0 or ) + * Nc Memory Area. See + * Siemens Memory Table (Used only in Siemens-Nc) + * Starting Index of Memory Area + * Set to 1 if the Byte is the second of a WORD (only for OSAI Nc) + * Reference to variable to read/Write + * */ + + public abstract CmsError MEM_RWByte(bool bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, int MemByte, ref byte Value); + + /** + * Read/Write unsigned 2 Byte (NC: Word:, .NET: ushort) variable from/into NC Memory Area (including Siemens Nc) + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Set True to Write-operation (Also Allowed /) + * Process to perform operation (If the area is process-indipendent use 0 or ) + * Nc Memory Area. See + * Siemens Memory Table (Used only in Siemens-Nc) + * Starting Index of Memory Area + * Number of sequential data Read/Write. (Used only in Reading Operation) + * List of values to read/Write + * */ + + public abstract CmsError MEM_RWWord(bool bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, ref ushort Value); + + /** + * Read/Write signed 2 Byte (NC: Word:, .NET: short) variable from/into NC Memory Area (including Siemens Nc) + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Set True to Write-operation (Also Allowed /) + * Process to perform operation (If the area is process-indipendent use 0 or ) + * Nc Memory Area. See + * Siemens Memory Table (Used only in Siemens-Nc) + * Starting Index of Memory Area + * Number of sequential data Read/Write. (Used only in Reading Operation) + * List of values to read/Write + * */ + + public abstract CmsError MEM_RWShort(bool bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, ref short Value); + + /** + * Read/Write signed 4 Byte (NC: DWord:, .NET: uint) variable from/into NC Memory Area (including Siemens Nc) + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * uW + * + * Returns an error when an internal or a library error occours + * Set True to Write-operation (Also Allowed /) + * Process to perform operation (If the area is process-indipendent use 0 or ) + * Nc Memory Area. See + * Siemens Memory Table (Used only in Siemens-Nc) + * Starting Index of Memory Area + * Number of sequential data Read/Write. (Used only in Reading Operation) + * List of values to read/Write + * */ + + public abstract CmsError MEM_RWDWord(bool bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, ref uint Value); + + + /** + * Read/Write signed 4 Byte (NC: DWord:, .NET: int) variable from/into NC Memory Area (including Siemens Nc) + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Set True to Write-operation (Also Allowed /) + * Process to perform operation (If the area is process-indipendent use 0 or ) + * Nc Memory Area. See + * Siemens Memory Table (Used only in Siemens-Nc) + * Starting Index of Memory Area + * Number of sequential data Read/Write. (Used only in Reading Operation) + * List of values to read/Write + * */ + + public abstract CmsError MEM_RWInteger(bool bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, ref int Value); + + + public abstract CmsError MEM_RWDouble(bool bWrite, int process, MEMORY_TYPE memType, int memTable, int memIndex, ref double value); + + #endregion MEMORY Low-level function: single valiable in memory (to override) + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + #region NC Low-level function: variables List in memory (to override) + + + /** + * Read/Write List of Byte from/into NC Memory Area (including Siemens Nc) + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Set True to Write-operation (Also Allowed /) + * Process to perform operation (If the area is process-indipendent use 0 or ) + * Nc Memory Area. See + * Siemens Memory Table (Used only in Siemens-Nc) + * Starting Index of Memory Area + * Set to 1 if the starting Byte is the second of a WORD (only for OSAI Nc) + * Number of sequential data Read/Write. (Used only in Reading Operation) + * List of values to read/Write + * */ + + public abstract CmsError MEM_RWByteList(bool bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, int MemByteStart, int Number, ref List Value); + + /** + * Read/Write List of unsigned 2 Byte (NC: Word:, .NET: ushort) from/into NC Memory Area (including Siemens Nc) + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Set True to Write-operation (Also Allowed /) + * Process to perform operation (If the area is process-indipendent use 0 or ) + * Nc Memory Area. See + * Siemens Memory Table (Used only in Siemens-Nc) + * Starting Index of Memory Area + * Number of sequential data Read/Write. (Used only in Reading Operation) + * List of values to read/Write + * */ + + public abstract CmsError MEM_RWWordList(bool bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, int Number, ref List Value); + + /** + * Read/Write List of signed 2 Byte (NC: Word:, .NET: short) from/into NC Memory Area (including Siemens Nc) + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Set True to Write-operation (Also Allowed /) + * Process to perform operation (If the area is process-indipendent use 0 or ) + * Nc Memory Area. See + * Siemens Memory Table (Used only in Siemens-Nc) + * Starting Index of Memory Area + * Number of sequential data Read/Write. (Used only in Reading Operation) + * List of values to read/Write + * */ + + public abstract CmsError MEM_RWShortList(bool bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, int Number, ref List Value); + + /** + * Read/Write List of unsigned 4 Byte (NC: DWord:, .NET: uint) from/into NC Memory Area (including Siemens Nc) + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Set True to Write-operation (Also Allowed /) + * Process to perform operation (If the area is process-indipendent use 0 or ) + * Nc Memory Area. See + * Siemens Memory Table (Used only in Siemens-Nc) + * Starting Index of Memory Area + * Number of sequential data Read/Write. (Used only in Reading Operation) + * List of values to read/Write + * */ + + public abstract CmsError MEM_RWDWordList(bool bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, int Number, ref List Value); + + /** + * Read/Write List of signed 4 Byte (NC: DWord:, .NET: int) from/into NC Memory Area (including Siemens Nc) + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Set True to Write-operation (Also Allowed /) + * Process to perform operation (If the area is process-indipendent use 0 or Nc.) + * Nc Memory Area. See + * Siemens Memory Table (Used only in Siemens-Nc) + * Starting Index of Memory Area + * Number of sequential data Read/Write. (Used only in Reading Operation) + * List of values to read/Write + * */ + + public abstract CmsError MEM_RWIntegerList(bool bWrite, int Process, MEMORY_TYPE MemType, int MemTable, int MemIndex, int Number, ref List Value); + + /** + * Read/Write List of signed 4 Byte (NC: DWord:, .NET: int) from/into NC Memory Area (including Siemens Nc) + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Set True to Write-operation (Also Allowed /) + * Process to perform operation (If the area is process-indipendent use 0 or Nc.) + * Nc Memory Area. See + * Siemens Memory Table (Used only in Siemens-Nc) + * Starting Index of Memory Area + * Number of sequential data Read/Write. (Used only in Reading Operation) + * List of values to read/Write + * */ + + public virtual CmsError MEM_RWDoubleList(bool bWrite, int process, MEMORY_TYPE memType, int memTable, int memIndex, int Number, ref List value) + { + return FUNCTION_NOT_ALLOWED_ERROR; + } + + #endregion NC Low-level function: variables List in memory (to override) + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + #region File Management (To override) + + /** + * Get file list of a specific path + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Directory path to read file list + * */ + + public abstract CmsError FILES_RGetFileList(string directoryPath, ref List files); + + /** + * Get file generic informations + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * File path to read file data + * */ + + public abstract CmsError FILES_RGetFileInfo(string filePath, ref InfoFile fileInfo); + + /** + * Set a program, stored in the NC, as active for the process + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Process where the program is going to be activated + * Path of the part program + * */ + + public abstract CmsError FILES_WSetActiveProgram(int processId, string filePath, ref ActiveProgramDataModel data); + + /** + * Deactivate active program on + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Process where the program is going to be deactivated + * */ + + public abstract CmsError FILES_WDeactivateProgram(int processId); + + /** + * Upload program into the NC memory + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Local path of the program + * New name of the program once has been saved + * Path of the program on the Nc memory + * */ + + public abstract CmsError FILES_UploadPartProgram(string localPath, string name, ref string newFilePath); + + /** + * Read active program on data + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Id of the process + * */ + + public abstract CmsError FILES_RActiveProgramData(int processId, ref ActiveProgramDataModel data); + + /** + * Read a Part Program by path and name + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Path of the Part Program stored in the Nc + * Name of the Part Program and name of new local file + * Reference to the new local file where the NC Part Program data will be saved + * */ + + public abstract CmsError FILES_RProgramToFile(string partProgramPath, FileStream localFile); + + /** + * Write/Overwrite a Part Program by path and name + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Path of the Part Program stored in the Nc + * Reference to the local Part Program file + * */ + + public abstract CmsError FILES_WProgramFromFile(string partProgramPath, FileStream localFile); + + /** + * Copy a Part Program into another path + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Path where the part program is going to be stored in the NC + * Path of the copy Part Program destination + * + * : Return an error if file exists. + * + * : Overwrite file if exists + * + * + */ + + public abstract CmsError FILES_CopyProgram(string partProgramPath, string newPartProgramPath, bool failIfExist); + + /** + * Delete a Nc Part Program + * + * Compatibility: Fanuc | Osai | Demo | Siemens + * + * + * Returns an error when an internal or a library error occours + * Path where the Nc Part Program is saved in the NC + * Name of the Part Program file + * */ + + public abstract CmsError FILES_DeleteProgram(string partProgramPath, string partProgramName); + + public abstract CmsError FILES_RQueueData(ref List statusList); + + public abstract CmsError FILES_RQueueDataByProcess(ref QueueStatusModel status, int processId); + + public abstract CmsError FILES_WStartQueue(); + + public abstract CmsError FILES_WStopQueue(); + + public abstract CmsError FILES_WLoadNextPartProgram(string localPath, string ncFileName); + + public abstract CmsError FILES_WUploadJobFilesAndActivate(int processId, string jobExtractedPath, string fileToActivate); + + public abstract CmsError FILES_RGetProgramType(ref PROGRAM_TYPE_ENUM programType); + + public abstract CmsError FILES_WCleanUploadFolder(); + + public abstract CmsError FILES_WUploadCustomMainProgramAndActivate(int processId, string customPartProgramContent, ref ActiveProgramDataModel activeData); + + #endregion File Management (To override) + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + #region Tool Table Siemens + + /** + * Read Adatpive Path Step + * + * Compatibility: Siemens + * + * + * Returns an error when an internal or a library error occours + * Reference to the tool table configuration data + **/ + + public abstract CmsError TOOLS_RAdatpivePathStep(ref Byte step); + + /** + * Write Adatpive Path Step + * + * Compatibility: Siemens + * + * + * Returns an error when an internal or a library error occours + * Reference to the tool table configuration data + **/ + + public abstract CmsError TOOLS_WAdatpivePathStep(Byte step); + + /** + * Read tool table configuration + * + * Compatibility: Siemens + * + * + * Returns an error when an internal or a library error occours + * Reference to the tool table configuration data + **/ + + public abstract CmsError TOOLS_RConfiguration(ref ToolTableConfiguration config); + + /** + * Read tools data from NC + * + * Compatibility: Siemens + * + * + * Returns an error when an internal or a library error occours + * Reference to the tools list data object + **/ + + public abstract CmsError TOOLS_RToolsData(ref List toolsData); + + /** + * Read shanks data from NC + * + * Compatibility: Siemens + * + * + * Returns an error when an internal or a library error occours + * Reference to the shank list data object + **/ + + public abstract CmsError TOOLS_RShanksData(ref List shanksData); + + /** + * Read families data + * + * Compatibility: Siemens + * + * + * Returns an error when an internal or a library error occours + * Reference to the tools families data object + **/ + + public abstract CmsError TOOLS_RFamilyData(ref List families); + + /** + * Read magazines positions data from NC + * + * Compatibility: Siemens + * + * + * Returns an error when an internal or a library error occours + * Reference to the tools list data object + **/ + + public abstract CmsError TOOLS_RMagazinePositions(ref List positions); + + /** + * Add a new tool + * + * Compatibility: Siemens + * + * + * Returns an error when an internal or a library error occours + **/ + + public abstract CmsError TOOLS_WAddTool(ref SiemensToolModel tool); + + /** + * Add a new family + * + * Compatibility: Siemens + * + * + * Returns an error when an internal or a library error occours + **/ + + public abstract CmsError TOOLS_WAddFamily(ref FamilyModel family); + + /** + * Add a new shank + * + * Compatibility: Siemens + * + * + * Returns an error when an internal or a library error occours + **/ + + public abstract CmsError TOOLS_WAddShank(ref ShankModel shank); + + /** + * Update family name + * + * Compatibility: Siemens + * + * + * Returns an error when an internal or a library error occours + * Family identifier + * New family name value + **/ + + public abstract CmsError TOOLS_WUpdateFamilyData(string oldName, string newName); + + /** + * Update magazine position data + * + * Compatibility: Siemens + * + * + * Returns an error when an internal or a library error occours + * New position data + **/ + + public abstract CmsError TOOLS_WUpdatePosition(PositionModel positionData); + + /** + * Update tool data + * + * Compatibility: Siemens + * + * + * Returns an error when an internal or a library error occours + * New tool data + **/ + + public abstract CmsError TOOLS_WUpdateTool(ref SiemensToolModel toolData); + + /** + * Delete tool + * + * Compatibility: Siemens + * + * + * Returns an error when an internal or a library error occours + * Tool identifier + **/ + + public abstract CmsError TOOLS_WDeleteTool(int id); + + /** + * Delete shank + * + * Compatibility: Siemens + * + * + * Returns an error when an internal or a library error occours + * Shank id + **/ + + public abstract CmsError TOOLS_WDeleteShank(int id); + + /** + * Delete family + * + * Compatibility: Siemens + * + * + * Returns an error when an internal or a library error occours + * Family identifier + **/ + + public abstract CmsError TOOLS_WDeleteFamily(string name); + + /** + * Delete edge + * + * Compatibility: Siemens + * + * + * Returns an error when an internal or a library error occours + * Tool id + * Edge id + **/ + + public abstract CmsError TOOLS_WDeleteEdge(int toolId, int edgeId); + + /** + * Add a new edge to tool + * + * Compatibility: Siemens + * + * + * Returns an error when an internal or a library error occours + * Tool id + **/ + + public abstract CmsError TOOLS_WAddEdge(int toolId, ref EdgeModel edge); + + /** + * Update edge + * + * Compatibility: Siemens + * + * + * Returns an error when an internal or a library error occours + * Tool id + * New edge data + **/ + + public abstract CmsError TOOLS_WUpdateEdge(int toolId, ref EdgeModel newEdge); + + /** + * Update shank + * + * Compatibility: Siemens + * + * + * Returns an error when an internal or a library error occours + * New shank data + **/ + + public abstract CmsError TOOLS_WUpdateShank(ref ShankModel shankData); + + /** + * Read mounted tool in magazine + * + * Compatibility: Siemens + * + * + * Returns an error when an internal or a library error occours + * Magazine id + **/ + + public abstract CmsError TOOLS_RMountedTools(int magazineId, ref List magazinePos); + + /** + * Read available tools/multitools (not mounted) + * + * Compatibility: Siemens + * + * + * Returns an error when an internal or a library error occours + * Magazine id + **/ + + public abstract CmsError TOOLS_RAvailableTools(ref List multitools, ref List tools); + + /** + * Load a tool in magazine + * + * Compatibility: Siemens + * + * + * Returns an error when an internal or a library error occours + * Magazine id + * Object that contains references to position id and tool id + **/ + + public abstract CmsError TOOLS_WLoadToolInMagazine(int magazineId, NewToolInMagazineModel newMagazineTool, ref MountedToolModel newMountedTool); + + /** + * Unload tool from magazine + * + * Compatibility: Siemens + * + * + * Returns an error when an internal or a library error occours + * Magazine id + * Position id + **/ + + public abstract CmsError TOOLS_WUnloadToolFromMagazine(int magazineId, int positionId); + + /** + * Load tool into shank + * + * Compatibility: Siemens + * + * + * Returns an error when an internal or a library error occours + * Shank id + * Position id + * Tool id + **/ + + public abstract CmsError TOOLS_WLoadToolIntoShank(int shankId, int positionId, int toolId); + + /** + * Unload tool from shank + * + * Compatibility: Siemens + * + * + * Returns an error when an internal or a library error occours + * Shank id + * Position id + **/ + + public abstract CmsError TOOLS_WUnloadToolFromShank(int shankId, int positionId); + + /** + * Get actual magazine status + * + * Compatibility: Siemens + * + * + * Returns an error when an internal or a library error occours + **/ + + public abstract CmsError TOOLS_RMagazineAction(ref MagazineActionModel magazineAction); + + public abstract CmsError TOOLS_WStartTDILoading(ushort magazineId, ushort positionId); + + public abstract CmsError TOOLS_WStartTDIUnloading(ushort magazineId, ushort positionId, ushort toolId); + + public abstract CmsError TOOLS_WEmptyBallufTablet(SiemensToolModel tool); + + public abstract CmsError TOOLS_WAbortBallufTablet(); + + #endregion Tool Table Siemens + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + #region Nc Tool Manager + + public abstract CmsError TOOLS_WOptions(ToolManagerOptionsModel options); + + public abstract CmsError TOOLS_ROffset(short offsetId, ref OffsetModel offset); + + public abstract CmsError TOOLS_WOffset(short offsetId, ref OffsetModel offset); + + public abstract CmsError TOOLS_WStartEditData(); + + public abstract CmsError TOOLS_WStopEditData(); + + public abstract CmsError TOOLS_WUpdateTools(List list); + + public abstract CmsError TOOLS_WUpdateFamilies(List list); + + public abstract CmsError TOOLS_WUpdateShanks(List list); + + public abstract CmsError TOOLS_WUpdateMagazinePositions(List list); + + public abstract CmsError TOOLS_WStartEditTooling(int magazineId); + + public abstract CmsError TOOLS_WStopEditTooling(int magazineId); + + public abstract CmsError TOOLS_WRestoreBackup(); + + public abstract CmsError TOOLS_RMagazineConfig(ref List config); + + public abstract CmsError TOOLS_RUpdatedToolsData(ref Dictionary updatedStatus, ref Dictionary updatedLives); + + public abstract CmsError TOOLS_RStoredData(ref List tools, ref List families, ref List shanks); + + public abstract CmsError TOOLS_RMagazineBlock(ref List ids); + + public abstract CmsError TOOLS_WFreeMagazines(); + + public abstract CmsError TOOLS_RMagazineStatus(ref Dictionary magazineStatus); + + #endregion Nc Tool Manager + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + #region CONSTANTS (Struct and Enum are Static for definition) + + public const int REFRESH_ALL_ALARMS_SFKEY_INDEX = 29; + // Read Write type + /** Write action */ + public const bool W = true; + /** Read action */ + public const bool R = false; + /** Not-Defined Process */ + public const ushort UNDEF_PROC = 0; + + + // NC Memory Type Name + internal const string FANUC_MEMTYPE = "Fanuc_"; + + internal const string SIEMENS_MEMTYPE = "Siemens_"; + internal const string OSAI_MEMTYPE = "Osai_"; + internal const string DEMO_MEMTYPE = "Demo_"; + internal const string UNDEFINED_MEMTYPE = "Null"; + + internal const string CUSTOM_MAIN_PROGRAM = "ACTIVE_LOADER_{0}"; + + // min-time to read static data (Cached values) + internal const ushort NC_MIN_SEC_READ_STATIC_DATA = 10; + + //Fanuc Variable & Const + internal const short FANUC_MAXNVAR = 1024; + + internal const short FANUC_MAXMSGCNC = 10; + internal const short FANUC_MAXMSGPMC = 5; + internal const short FANUC_ABSOLUTEPOS = 0; + internal const short FANUC_MACHINEPOS = 1; + internal const short FANUC_RELATIVEPOS = 2; + internal const short FANUC_DISTTOGO = 3; + internal const short FANUC_ALLPOS = -1; + + internal enum FANUC_DType : short { BYTE = 0, WORD = 1, LONG = 2 }; + + internal const ushort OSAI_PROGRAMMEDPOS = 1; + internal const ushort OSAI_INTERPOLPOS = 2; + internal const ushort OSAI_TRANSDUCERPOS = 3; + internal const ushort OSAI_FOLLERROR = 4; + internal const ushort OSAI_DISTTOGO = 5; + internal const ushort OSAI_MACHINEPOS = 6; + + /** Nc Screen */ + + public enum SCREEN_PAGE + { + //Siemens + Siemens_Machine = 100, + + Siemens_Parameter = 101, + Siemens_Program = 102, + Siemens_ProgramManager = 103, + Siemens_Diagnostics = 104, + Siemens_Setup = 105, + + //Fanuc + Fanuc_Pos = 200, + + Fanuc_Prog = 201, + Fanuc_Offset = 202, + Fanuc_System = 203, + Fanuc_Message = 204, + Fanuc_MGI = 205, + Fanuc_Graph = 206, + Fanuc_Custom2 = 207, + } + + #endregion CONSTANTS (Struct and Enum are Static for definition) + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + #region Fixed memory area + + // TODO REMOVE + //Lingua CN + internal MEMORY_CELL PARAM_LING_FANUC = new MEMORY_CELL(MEMORY_TYPE.Null, 3281, 0, 1); + + internal MEMORY_CELL PARAM_LING_FANUC_W = new MEMORY_CELL(MEMORY_TYPE.Fanuc_G, 581, 0, 1); + + #endregion Fixed memory area + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + #region Helper Function + + internal void AddNcAlarmToList(uint id, string message, DateTime dateTime, List alarms) + { + alarms.Add(new AlarmModel() + { + Id = id, + Message = message, + IsWarning = false, + Process = 0, + DateTime = dateTime + }); + } + + internal void AddAlarmToList(int id, short axisId, string message, int process, DateTime dateTime, List alarms) + { + alarms.Add(new AlarmModel() + { + Id = Convert.ToUInt32((id & 0xffff) | (axisId << 24)), // Set last byte with axisId in order to have unique ids + Message = message, + IsWarning = false, + Process = process, + DateTime = dateTime + }); + } + + internal void AddAlarmToList(uint id, string message, int process, List alarms) + { + alarms.Add(new AlarmModel() + { + Id = id, + Message = message, + IsWarning = false, + Process = process + }); + } + + internal void AddPlcAlarmsToList(uint id, bool isWaring, bool restorationIsActive, List processes, List alarms) + { + alarms.Add(new PlcAlarmModel() + { + Id = id, + IsWarning = isWaring, + RestorationIsActive = restorationIsActive, + Process = processes + }); + } + + #endregion Helper Function + } +} \ 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 ef03a2c..6ab5803 100644 --- a/CMS_CORE_Library/Osai/Nc_Osai.cs +++ b/CMS_CORE_Library/Osai/Nc_Osai.cs @@ -1695,17 +1695,6 @@ namespace CMS_CORE_Library.Osai /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - #region THERMO high level data - - public override CmsError PLC_RRecipeParamList(bool onlyRT, ref Dictionary currParamList) - { - return FUNCTION_NOT_ALLOWED_ERROR; - } - - #endregion THERMO high level data - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - #region PROCESS (PATH) High-level data //Get the process status diff --git a/CMS_CORE_Library/S7Net/Nc_S7Net.cs b/CMS_CORE_Library/S7Net/Nc_S7Net.cs index 29503d5..6b06c42 100644 --- a/CMS_CORE_Library/S7Net/Nc_S7Net.cs +++ b/CMS_CORE_Library/S7Net/Nc_S7Net.cs @@ -13,15 +13,16 @@ using System.Text.RegularExpressions; using System.Threading; using System.Xml.Linq; using static CMS_CORE_Library.Models.DataStructures; -using static CMS_CORE_Library.Nc; +using static CMS_CORE_Library.NcThermo; +using static CMS_CORE_Library.Models.ThermoModels; +using static CMS_CORE_Library.Nc.MEMORY_TYPE; using static CMS_CORE_Library.S7Net.MEMORY_ADDRESS; -using static CMS_CORE_Library.ToolConfigurations; using static CMS_CORE_Library.Utils.Nc_Utils; - +using static CMS_CORE_Library.Nc; namespace CMS_CORE_Library.S7Net { - public class Nc_S7Net : Nc + public class Nc_S7Net : NcThermo { // Global Constants @@ -1155,7 +1156,7 @@ namespace CMS_CORE_Library.S7Net if (cmsError.IsError()) return cmsError; - cmsError = MEM_RWByteList(R, 0, M156_INPUT_ID_LIST.MemType, M156_INPUT_ID_LIST.Address, 0, M156_INPUT_ID_LIST.Size, ref vals); + cmsError = MEM_RWByteList(R, 0, M156_INPUT_ID_LIST.MemType, M156_INPUT_ID_LIST.Address, M156_INPUT_ID_LIST.SubAddress, 0, M156_INPUT_ID_LIST.Size, ref vals); if (cmsError.IsError()) return cmsError; @@ -1946,7 +1947,7 @@ namespace CMS_CORE_Library.S7Net return INCORRECT_PARAMETERS_ERROR; // Write process number - cmsError = MEM_RWByte(W, 0, SELECT_PROCESS.MemType, SELECT_PROCESS.Address, SELECT_PROCESS.SubAddress, ref processNum); + cmsError = MEM_RWByte(W, 0, SELECT_PROCESS.MemType, SELECT_PROCESS.Address, SELECT_PROCESS.SubAddress, 0, ref processNum); if (cmsError.IsError()) return cmsError; @@ -2117,6 +2118,40 @@ namespace CMS_CORE_Library.S7Net #region THERMO high level data + /// + /// Get gauge data + /// + /// + /// + public override CmsError PLC_RGaugeData(ref GaugeModel gaugeData) + { + List Values = new List(); + // TODO FIXME quando disponibile memoria... + gaugeData = new GaugeModel() + { + TimeAdv = 1, + Power = 2, + Vacuum = 3, + Air = 4, + }; +#if false + CmsError cmsError = MEM_RWIntegerList(R, 1, MACHINE_GAUGE_DATA.MemType, MACHINE_GAUGE_DATA.Address, MACHINE_GAUGE_DATA.SubAddress, MACHINE_GAUGE_DATA.Size, ref Values); + + if (cmsError.IsError()) + return cmsError; + + gaugeData = new GaugeModel() + { + TimeAdv = Convert.ToUInt32(Values[0]), + Power = Values[1], + Vacuum = Values[2], + Air = Values[3], + }; +#endif + + return NO_ERROR; + } + public override CmsError PLC_RRecipeParamList(bool onlyRT, ref Dictionary currParamList) { // refresh dati veloci / RT @@ -2137,63 +2172,70 @@ namespace CMS_CORE_Library.S7Net List currMem = new List(); // leggo da PLC a array di byte di appoggio... - CmsError cmsError = MEM_RWByteList(R, 0, PARAMETER_RT_DATA.MemType, PARAMETER_RT_DATA.Address, PARAMETER_RT_DATA.SubAddress, PARAMETER_RT_DATA.Size, ref currMem); + CmsError cmsError = MEM_RWByteList(R, 0, PARAMETER_RT_DATA.MemType, PARAMETER_RT_DATA.Address, PARAMETER_RT_DATA.SubAddress, 0, PARAMETER_RT_DATA.Size, ref currMem); int packSize = 8; - // converto a blocchi di 8 byte... - byte[] memArray = currMem.ToArray(); - for (int i = 0; i < PARAMETER_RT_DATA.Size / packSize; i++) + // controllo SE ho dati... + if (currMem.Count > 0) { - PlcParamRT currParam = new PlcParamRT(memArray.Skip(i * packSize).Take(packSize).ToArray()); - // solo se ID > 0... - if (currParam.Id > 0) + // converto a blocchi di 8 byte... + byte[] memArray = currMem.ToArray(); + for (int i = 0; i < PARAMETER_RT_DATA.Size / packSize; i++) { - // update oggetto thermoParamList... - if (thermoParamList.ContainsKey(currParam.Id)) + PlcParamRT currParam = new PlcParamRT(memArray.Skip(i * packSize).Take(packSize).ToArray()); + // solo se ID > 0... + if (currParam.Id > 0) { - thermoParamList[currParam.Id].Enabled = currParam.Enabled; - thermoParamList[currParam.Id].HasError = currParam.HasError; - thermoParamList[currParam.Id].Visible = currParam.Visible; - thermoParamList[currParam.Id].ValueAct = currParam.ValueAct; - } - else - { - thermoParamList.Add(currParam.Id, new RecipeParam() { Id = currParam.Id, Enabled = currParam.Enabled, HasError = currParam.HasError, Visible = currParam.Visible, ValueAct = currParam.ValueAct }); + // update oggetto thermoParamList... + if (thermoParamList.ContainsKey(currParam.Id)) + { + thermoParamList[currParam.Id].Enabled = currParam.Enabled; + thermoParamList[currParam.Id].HasError = currParam.HasError; + thermoParamList[currParam.Id].Visible = currParam.Visible; + thermoParamList[currParam.Id].ValueAct = currParam.ValueAct; + } + else + { + thermoParamList.Add(currParam.Id, new RecipeParam() { Id = currParam.Id, Enabled = currParam.Enabled, HasError = currParam.HasError, Visible = currParam.Visible, ValueAct = currParam.ValueAct }); + } } } } - } protected void refreshMemRecipeParameter() { List currMem = new List(); // leggo da PLC a array di byte di appoggio... - CmsError cmsError = MEM_RWByteList(R, 0, PARAMETER_DATA.MemType, PARAMETER_DATA.Address, PARAMETER_DATA.SubAddress, PARAMETER_DATA.Size, ref currMem); + CmsError cmsError = MEM_RWByteList(R, 0, PARAMETER_DATA.MemType, PARAMETER_DATA.Address, PARAMETER_DATA.SubAddress, 0, PARAMETER_DATA.Size, ref currMem); int packSize = 20; - // converto a blocchi di 8 byte... - byte[] memArray = currMem.ToArray(); - for (int i = 0; i < PARAMETER_DATA.Size / packSize; i++) + // controllo SE ho dati... + if (currMem.Count > 0) { - PlcParam currParam = new PlcParam(memArray.Skip(i * packSize).Take(packSize).ToArray()); - // solo se ID > 0... - if (currParam.Id > 0) + // converto a blocchi di 8 byte... + byte[] memArray = currMem.ToArray(); + for (int i = 0; i < PARAMETER_DATA.Size / packSize; i++) { - // update oggetto thermoParamList... - if (thermoParamList.ContainsKey(currParam.Id)) + PlcParam currParam = new PlcParam(memArray.Skip(i * packSize).Take(packSize).ToArray()); + // solo se ID > 0... + if (currParam.Id > 0) { - thermoParamList[currParam.Id].SetpointHMI = currParam.SetpointHMI; - thermoParamList[currParam.Id].SetpointPLC = currParam.SetpointPLC; - thermoParamList[currParam.Id].ValMax = currParam.ValMax; - thermoParamList[currParam.Id].ValMin = currParam.ValMin; - thermoParamList[currParam.Id].UnitMeasure = currParam.UnitMeasure; - } - else - { - thermoParamList.Add(currParam.Id, new RecipeParam() { Id = currParam.Id, SetpointHMI = currParam.SetpointHMI, SetpointPLC = currParam.SetpointPLC, ValMax = currParam.ValMax, ValMin = currParam.ValMin, UnitMeasure = currParam.UnitMeasure }); + // update oggetto thermoParamList... + if (thermoParamList.ContainsKey(currParam.Id)) + { + thermoParamList[currParam.Id].SetpointHMI = currParam.SetpointHMI; + thermoParamList[currParam.Id].SetpointPLC = currParam.SetpointPLC; + thermoParamList[currParam.Id].ValMax = currParam.ValMax; + thermoParamList[currParam.Id].ValMin = currParam.ValMin; + thermoParamList[currParam.Id].UnitMeasure = currParam.UnitMeasure; + } + else + { + thermoParamList.Add(currParam.Id, new RecipeParam() { Id = currParam.Id, SetpointHMI = currParam.SetpointHMI, SetpointPLC = currParam.SetpointPLC, ValMax = currParam.ValMax, ValMin = currParam.ValMin, UnitMeasure = currParam.UnitMeasure }); + } } } } @@ -2595,7 +2637,7 @@ namespace CMS_CORE_Library.S7Net ushort pow = (ushort)Math.Pow(2, MemBit); //Read the Byte where is the bit - cmsError = MEM_RWByte(R, Process, MemType, MemTable, MemIndex, ref bValue); + cmsError = MEM_RWByte(R, Process, MemType, MemTable, MemIndex, 0, ref bValue); if (cmsError.IsError()) return cmsError; @@ -2607,7 +2649,7 @@ namespace CMS_CORE_Library.S7Net else bValue = (byte)(bValue & ~(1 << MemBit)); - cmsError = MEM_RWByte(W, Process, MemType, MemTable, MemIndex, ref bValue); + cmsError = MEM_RWByte(W, Process, MemType, MemTable, MemIndex, 0, ref bValue); if (cmsError.IsError()) return cmsError; } @@ -2710,68 +2752,6 @@ namespace CMS_CORE_Library.S7Net return NO_ERROR; } - //-------------------------------------------------------------------------------------------------------------------------- - // Other-NC Version of Memory-Access Methods - - public override CmsError MEM_RWBoolean(bool bWrite, int Process, MEMORY_TYPE MemType, int MemIndex, int MemBit, ref bool Value) - { - return FUNCTION_NOT_ALLOWED_ERROR; - } - - public override CmsError MEM_RWByte(bool bWrite, int Process, MEMORY_TYPE MemType, int MemIndex, int MemByte, ref byte Value) - { - return FUNCTION_NOT_ALLOWED_ERROR; - } - - public override CmsError MEM_RWDWord(bool bWrite, int Process, MEMORY_TYPE MemType, int MemIndex, ref uint Value) - { - return FUNCTION_NOT_ALLOWED_ERROR; - } - - public override CmsError MEM_RWInteger(bool bWrite, int Process, MEMORY_TYPE MemType, int MemIndex, ref int Value) - { - return FUNCTION_NOT_ALLOWED_ERROR; - } - - public override CmsError MEM_RWShort(bool bWrite, int Process, MEMORY_TYPE MemType, int MemIndex, ref short Value) - { - return FUNCTION_NOT_ALLOWED_ERROR; - } - - public override CmsError MEM_RWWord(bool bWrite, int Process, MEMORY_TYPE MemType, int MemIndex, ref ushort Value) - { - return FUNCTION_NOT_ALLOWED_ERROR; - } - - public override CmsError MEM_RWDouble(bool bWrite, int process, MEMORY_TYPE memType, int memIndex, ref double value) - { - return FUNCTION_NOT_ALLOWED_ERROR; - } - - public override CmsError MEM_RWDWordList(bool bWrite, int Process, MEMORY_TYPE MemType, int MemIndex, int Number, ref List Value) - { - return FUNCTION_NOT_ALLOWED_ERROR; - } - - public override CmsError MEM_RWIntegerList(bool bWrite, int Process, MEMORY_TYPE MemType, int MemIndex, int Number, ref List Value) - { - return FUNCTION_NOT_ALLOWED_ERROR; - } - - public override CmsError MEM_RWShortList(bool bWrite, int Process, MEMORY_TYPE MemType, int MemIndex, int Number, ref List Value) - { - return FUNCTION_NOT_ALLOWED_ERROR; - } - - public override CmsError MEM_RWWordList(bool bWrite, int Process, MEMORY_TYPE MemType, int MemIndex, int Number, ref List Value) - { - return FUNCTION_NOT_ALLOWED_ERROR; - } - - public override CmsError MEM_RWByteList(bool bWrite, int Process, MEMORY_TYPE MemType, int MemIndex, int MemByteStart, int Number, ref List Value) - { - return FUNCTION_NOT_ALLOWED_ERROR; - } #endregion NC Low-level function: single valiable in memory @@ -2808,9 +2788,13 @@ namespace CMS_CORE_Library.S7Net return NO_ERROR; Values.Clear(); - - var memByteRead = currPLC.ReadBytes(DataType.DataBlock, MemTable, MemIndex, Number); - Values = memByteRead.ToList(); + try + { + var memByteRead = currPLC.ReadBytes(DataType.DataBlock, MemTable, MemIndex, Number); + Values = memByteRead.ToList(); + } + catch + { } } return NO_ERROR; @@ -3013,8 +2997,15 @@ namespace CMS_CORE_Library.S7Net return NO_ERROR; Values.Clear(); - - byte[] memByteRead = currPLC.ReadBytes(DataType.DataBlock, MemTable, MemIndex, Number); + byte[] memByteRead = null; + try + { + memByteRead = currPLC.ReadBytes(DataType.DataBlock, MemTable, MemIndex, Number); + } + catch + { + return PLC_MEM_CONF_ERROR; + } // converto a word! int shortVal = 0; for (int i = 0; i < memByteRead.Length / 4; i++) @@ -3024,6 +3015,11 @@ namespace CMS_CORE_Library.S7Net } } + if (Values.Count == 0) + { + return NOT_CONNECTED_ERROR; + } + return NO_ERROR; } @@ -4246,7 +4242,8 @@ namespace CMS_CORE_Library.S7Net // Machine number internal static MEMORY_CELL NEW_MATR_MACC = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 604, 6720, 4); - + // generic machine gauge data + internal static MEMORY_CELL MACHINE_GAUGE_DATA = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, 605, 6, 8); internal static MEMORY_CELL NC_WATCHDOG = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 0, 1); diff --git a/CMS_CORE_Library/Siemens/Nc_Siemens.cs b/CMS_CORE_Library/Siemens/Nc_Siemens.cs index 72e977e..ea0d2ac 100644 --- a/CMS_CORE_Library/Siemens/Nc_Siemens.cs +++ b/CMS_CORE_Library/Siemens/Nc_Siemens.cs @@ -2113,17 +2113,6 @@ namespace CMS_CORE_Library.Siemens /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - #region THERMO high level data - - public override CmsError PLC_RRecipeParamList(bool onlyRT, ref Dictionary currParamList) - { - return FUNCTION_NOT_ALLOWED_ERROR; - } - - #endregion THERMO high level data - - /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - #region PROCESS (PATH) High-level data // Get the process Mode