diff --git a/CMS_CORE_Application/Form1.Designer.cs b/CMS_CORE_Application/Form1.Designer.cs index 892cf86..53c81ee 100644 --- a/CMS_CORE_Application/Form1.Designer.cs +++ b/CMS_CORE_Application/Form1.Designer.cs @@ -30,6 +30,7 @@ { this.Connect = new System.Windows.Forms.Button(); this.panel1 = new System.Windows.Forms.Panel(); + this.pathTextBox = new System.Windows.Forms.TextBox(); this.NetworkReadButton = new System.Windows.Forms.Button(); this.writeFileBtn = new System.Windows.Forms.Button(); this.readFileBtn = new System.Windows.Forms.Button(); @@ -82,7 +83,7 @@ this.label7 = new System.Windows.Forms.Label(); this.label10 = new System.Windows.Forms.Label(); this.Error = new System.Windows.Forms.TextBox(); - this.pathTextBox = new System.Windows.Forms.TextBox(); + this.button1 = new System.Windows.Forms.Button(); this.panel1.SuspendLayout(); this.tableLayoutPanel3.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); @@ -117,6 +118,7 @@ | System.Windows.Forms.AnchorStyles.Right))); this.panel1.BackColor = System.Drawing.Color.White; this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.panel1.Controls.Add(this.button1); this.panel1.Controls.Add(this.pathTextBox); this.panel1.Controls.Add(this.NetworkReadButton); this.panel1.Controls.Add(this.writeFileBtn); @@ -133,6 +135,13 @@ this.panel1.Size = new System.Drawing.Size(650, 128); this.panel1.TabIndex = 1; // + // pathTextBox + // + this.pathTextBox.Location = new System.Drawing.Point(19, 51); + this.pathTextBox.Name = "pathTextBox"; + this.pathTextBox.Size = new System.Drawing.Size(244, 20); + this.pathTextBox.TabIndex = 10; + // // NetworkReadButton // this.NetworkReadButton.Location = new System.Drawing.Point(188, 13); @@ -394,7 +403,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, 293F)); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 294F)); this.tableLayoutPanel1.Controls.Add(this.groupBox2, 1, 0); this.tableLayoutPanel1.Controls.Add(this.groupBox1, 0, 0); this.tableLayoutPanel1.Controls.Add(this.groupBox4, 2, 0); @@ -413,7 +422,7 @@ | System.Windows.Forms.AnchorStyles.Right))); this.groupBox2.Controls.Add(this.TXTMsg); this.groupBox2.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.groupBox2.Location = new System.Drawing.Point(160, 3); + this.groupBox2.Location = new System.Drawing.Point(159, 3); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(146, 265); this.groupBox2.TabIndex = 28; @@ -440,7 +449,7 @@ this.groupBox1.Controls.Add(this.TXTAlmNc); this.groupBox1.Location = new System.Drawing.Point(3, 3); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(151, 265); + this.groupBox1.Size = new System.Drawing.Size(150, 265); this.groupBox1.TabIndex = 27; this.groupBox1.TabStop = false; this.groupBox1.Text = "Nc"; @@ -454,7 +463,7 @@ this.TXTAlmNc.Multiline = true; this.TXTAlmNc.Name = "TXTAlmNc"; this.TXTAlmNc.ReadOnly = true; - this.TXTAlmNc.Size = new System.Drawing.Size(139, 240); + this.TXTAlmNc.Size = new System.Drawing.Size(138, 240); this.TXTAlmNc.TabIndex = 20; // // groupBox4 @@ -464,9 +473,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(312, 3); + this.groupBox4.Location = new System.Drawing.Point(311, 3); this.groupBox4.Name = "groupBox4"; - this.groupBox4.Size = new System.Drawing.Size(288, 265); + this.groupBox4.Size = new System.Drawing.Size(289, 265); this.groupBox4.TabIndex = 29; this.groupBox4.TabStop = false; this.groupBox4.Text = "Path"; @@ -480,7 +489,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(275, 238); + this.tabControl1.Size = new System.Drawing.Size(276, 238); this.tabControl1.TabIndex = 0; // // tabPage1 @@ -489,7 +498,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(267, 212); + this.tabPage1.Size = new System.Drawing.Size(268, 212); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "Path 1"; this.tabPage1.UseVisualStyleBackColor = true; @@ -503,7 +512,7 @@ this.TXTAlm.Multiline = true; this.TXTAlm.Name = "TXTAlm"; this.TXTAlm.ReadOnly = true; - this.TXTAlm.Size = new System.Drawing.Size(255, 203); + this.TXTAlm.Size = new System.Drawing.Size(256, 203); this.TXTAlm.TabIndex = 18; // // groupBox3 @@ -717,12 +726,15 @@ this.Error.Size = new System.Drawing.Size(462, 20); this.Error.TabIndex = 27; // - // pathTextBox + // button1 // - this.pathTextBox.Location = new System.Drawing.Point(19, 51); - this.pathTextBox.Name = "pathTextBox"; - this.pathTextBox.Size = new System.Drawing.Size(244, 20); - this.pathTextBox.TabIndex = 10; + this.button1.Location = new System.Drawing.Point(286, 51); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.TabIndex = 11; + this.button1.Text = "Leggi rete"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); // // Form1 // @@ -821,6 +833,7 @@ private System.Windows.Forms.Button readFileBtn; private System.Windows.Forms.Button NetworkReadButton; private System.Windows.Forms.TextBox pathTextBox; + private System.Windows.Forms.Button button1; } } diff --git a/CMS_CORE_Application/Form1.cs b/CMS_CORE_Application/Form1.cs index fcda260..65d834f 100644 --- a/CMS_CORE_Application/Form1.cs +++ b/CMS_CORE_Application/Form1.cs @@ -77,7 +77,7 @@ namespace CMS_CORE_Application CmsError cmsError = N.NC_Connect(); cmsError = N.NC_RModelName(ref ModelName); - cmsError = N.NC_WLanguage(new System.Globalization.CultureInfo("it")); + //cmsError = N.NC_WLanguage(new System.Globalization.CultureInfo("it")); bool error = false; string serial = ""; @@ -421,5 +421,10 @@ namespace CMS_CORE_Application }; N.TOOLS_WUpdateTools(obj); } + + private void button1_Click(object sender, EventArgs e) + { + N.NC_SetScreenVisible(Nc.SCREEN_PAGE.Siemens_Machine); + } } } \ No newline at end of file diff --git a/CMS_CORE_Library/Demo/Nc_Demo.cs b/CMS_CORE_Library/Demo/Nc_Demo.cs index b822acc..779206b 100644 --- a/CMS_CORE_Library/Demo/Nc_Demo.cs +++ b/CMS_CORE_Library/Demo/Nc_Demo.cs @@ -314,6 +314,11 @@ namespace CMS_CORE.Demo return NO_ERROR; } + public override CmsError NC_SetScreenVisible(SCREEN_PAGE screen) + { + return NO_ERROR; + } + #endregion High level methods /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs index 6725f59..73e1cab 100644 --- a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs +++ b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs @@ -335,6 +335,39 @@ namespace CMS_CORE.Fanuc return NO_ERROR; } + //Set the Nc Active Page of the NC + public override CmsError NC_SetScreenVisible(SCREEN_PAGE screen) + { + short actualPage, nReturn; + + //Check if the NC is Connected + CmsError cmsError = CheckConnection(); + if (cmsError.IsError()) + return cmsError; + + //Convert to Fanuc Ref + short pageToGo = (short)ConvertStepToFanucScreen(screen); + + //Read actual page + nReturn = Focas1.cnc_getcurscrn(nLibHandle[0], out actualPage); + + //Throw Exception if there's an error + if (nReturn != 0) + return GetNcError(nReturn); + + //Write the new page + if (pageToGo!=0 && actualPage != pageToGo) + { + nReturn = Focas1.cnc_setcurscrn(nLibHandle[0], pageToGo); + + //Throw Exception if there's an error + if (nReturn != 0) + return GetNcError(nReturn); + } + + return NO_ERROR; + } + #endregion High level methods /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1948,6 +1981,22 @@ namespace CMS_CORE.Fanuc #region Subordinate Private Functions + private Focas1.page_code ConvertStepToFanucScreen(SCREEN_PAGE page) + { + switch (page) + { + case SCREEN_PAGE.Fanuc_Pos: return Focas1.page_code.ABS; + case SCREEN_PAGE.Fanuc_Prog: return Focas1.page_code.PROG; + case SCREEN_PAGE.Fanuc_Offset: return Focas1.page_code.OFFSET; + case SCREEN_PAGE.Fanuc_Message: return Focas1.page_code.ALARM; + case SCREEN_PAGE.Fanuc_System: return Focas1.page_code.PARAM; + case SCREEN_PAGE.Fanuc_Custom1: return Focas1.page_code.TMAC1; + case SCREEN_PAGE.Fanuc_Custom2: return Focas1.page_code.TMAC2; + case SCREEN_PAGE.Fanuc_Graph: return Focas1.page_code.GRAPH; + default: return 0; + } + } + private CmsError ErrorHandler(short exNum) { if (exNum != 0) diff --git a/CMS_CORE_Library/Fanuc/fwlib32_64.cs b/CMS_CORE_Library/Fanuc/fwlib32_64.cs index 9b7a96a..6da2618 100644 --- a/CMS_CORE_Library/Fanuc/fwlib32_64.cs +++ b/CMS_CORE_Library/Fanuc/fwlib32_64.cs @@ -11753,5 +11753,143 @@ public class Focas1 public static extern short cnc_rdetherinfo(ushort FlibHndl, out short a, out short b); + /*--------------------------*/ + /* Cursor Screen */ + /*--------------------------*/ + + [DllImport(FOCAS_LIB_NAME, EntryPoint = "cnc_setcurscrn")] + public static extern short cnc_setcurscrn(ushort FlibHndl, short scrn_no); + + [DllImport(FOCAS_LIB_NAME, EntryPoint = "cnc_getcurscrn")] + public static extern short cnc_getcurscrn(ushort FlibHndl, out short scrn_no); + + + public enum page_code: short + { + //POSITION + ABS = 0x0100, + REL = 0x0200, + ALL = 0x0300, + HNDL = 0x0400, + MONITOR = 0x0600, + AXMAN5 = 0X0700, + C_EXECUTOR_PO = 0X3200, + C_EXECUTOR_2_PO = 0X3300, + C_EXECUTOR_3_PO = 0X3400, + C_EXECUTOR_4_PO = 0X3500, + C_EXECUTOR_5_PO = 0X3600, + + //PROGRAM + PROG = 0X0101, + FOLDER = 0X0201, + NEXT = 0X0301, + CHECK = 0X0401, + STAMP = 0X0601, + JOG = 0X0701, + RSTR = 0X0801, + C_EXECUTOR_PR = 0X3201, + C_EXECUTOR_2_PR = 0X3301, + C_EXECUTOR_3_PR = 0X3401, + C_EXECUTOR_4_PR = 0X3501, + C_EXECUTOR_5_PR = 0X3601, + + //OFFSET + OFFSET = 0X0102, + SETTING = 0X0202, + WORK = 0X0302, + MACRO = 0X0602, + OPR = 0X0802, + TOOL_MANAGER = 0X0902, + OFST_2=0X0B02, + W_SHFT = 0X0C02, + GEOM_2=0X0D02, + TOOL_F = 0X0E02, + MODEM = 0X1002, + PR_LEV = 0X1102, + CHOP = 0X1302, + CHUCK_TAIL = 0X1502, + LANG=0X1602, + PROTECT = 0X1702, + GUARD = 0X1802, + ACTFIX = 0X1A02, + RTTFIX = 0X1B02, + C_EXECUTOR_O = 0X3202, + C_EXECUTOR_2_O = 0X3302, + C_EXECUTOR_3_O = 0X3402, + C_EXECUTOR_4_O = 0X3502, + C_EXECUTOR_5_O = 0X3602, + + //SYSTEM + PARAM = 0X0103, + DGNOS = 0X0203, + SERVO_GUIDEM = 0X0303, + SYSTEM = 0X0403, + MEMORY = 0X0603, + PITCH = 0X0703, + SV_PRM = 0X0803, + SP_SET = 0X0903, + PMC_MAINTE = 0X0B03, + PMC_LADDER = 0X0C03, + PMC_CONFIG = 0X0D03, + M_TUN = 0X1003, + ALL_IO = 0X1103, + ALL_IO2 = 0X1203, + OPEHIS = 0X1303, + COLOR = 0X1503, + MAINTE = 0X1603, + M_INFO = 0X1703, + W_DGNS = 0X1803, + TOUCH = 0X1A03, + FSSB = 0X1B03, + PRMTUN = 0X1C03, + PMM = 0X1D03, + EMBED_PORT = 0X1F03, + PCMCIA_LAN = 0X2003, + ETHER_BOARD = 0X2103, + PROFI_MASTER = 0X2203, + RMTDGN = 0X2403, + M_CODE = 0X2503, + LEARNCTRL = 0X2603, + ADJUST3D = 0X2703, + C_EXECUTOR_S = 0X3203, + C_EXECUTOR_2_S = 0X3303, + C_EXECUTOR_3_S = 0X3403, + C_EXECUTOR_4_S = 0X3503, + C_EXECUTOR_5_S = 0X3603, + + //MESSAGE + ALARM = 0X0104, + MSG = 0X0204, + HISTRY = 0X0304, + MSGHIS = 0X0404, + EMBED_LOG = 0X0604, + PCMCIA_LOG = 0X0704, + BOARD_LOG = 0X0804, + C_EXECUTOR_M = 0X3204, + C_EXECUTOR_2_M = 0X3304, + C_EXECUTOR_3_M = 0X3404, + C_EXECUTOR_4_M = 0X3504, + C_EXECUTOR_5_M = 0X3604, + + //GRAPHIC + PARAMETER = 0X0105, + GRAPH = 0X0205, + C_EXECUTOR_G = 0X3205, + C_EXECUTOR_2_G = 0X3305, + C_EXECUTOR_3_G = 0X3405, + C_EXECUTOR_4_G = 0X3505, + C_EXECUTOR_5_G = 0X3605, + + //CUSTOM + TMAC1 = 0X0106, + TMAC2 = 0X0206, + TMAC3 = 0X0306, + C_EXECUTOR_C = 0X3206, + C_EXECUTOR_2_C = 0X3306, + C_EXECUTOR_3_C = 0X3406, + C_EXECUTOR_4_C = 0X3506, + C_EXECUTOR_5_C = 0X3606 + }; + } // End for Focas1 class diff --git a/CMS_CORE_Library/Nc.cs b/CMS_CORE_Library/Nc.cs index 4b02f11..20de4e7 100644 --- a/CMS_CORE_Library/Nc.cs +++ b/CMS_CORE_Library/Nc.cs @@ -362,6 +362,22 @@ namespace CMS_CORE public abstract CmsError NC_GetTranslatedPlcMessages(string language, ref Dictionary messages); + + + /** + * + * 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); + + #endregion NC High-level data (to override) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1843,6 +1859,29 @@ namespace CMS_CORE 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 = 201, + Fanuc_Prog = 202, + Fanuc_Offset = 203, + Fanuc_Message = 204, + Fanuc_Graph = 205, + Fanuc_Custom1 = 206, + Fanuc_Custom2 = 207, + Fanuc_System = 208 + + } #endregion CONSTANTS (Struct and Enum are Static for definition) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/CMS_CORE_Library/Osai/Nc_Osai.cs b/CMS_CORE_Library/Osai/Nc_Osai.cs index fa34f6d..1589375 100644 --- a/CMS_CORE_Library/Osai/Nc_Osai.cs +++ b/CMS_CORE_Library/Osai/Nc_Osai.cs @@ -386,6 +386,12 @@ namespace CMS_CORE.Osai return NO_ERROR; } + //Set the Nc Active Page of the NC + public override CmsError NC_SetScreenVisible(SCREEN_PAGE screen) + { + return NO_ERROR; + } + #endregion High-level Methods /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/CMS_CORE_Library/Siemens/Nc_Siemens.cs b/CMS_CORE_Library/Siemens/Nc_Siemens.cs index 8f80159..ab5aa52 100644 --- a/CMS_CORE_Library/Siemens/Nc_Siemens.cs +++ b/CMS_CORE_Library/Siemens/Nc_Siemens.cs @@ -1,4 +1,5 @@ -using CMS_CORE_Library.Siemens; +using CMS_CORE_Library; +using CMS_CORE_Library.Siemens; using Siemens.Sinumerik.Operate.Services; using System; using System.Collections; @@ -516,6 +517,18 @@ namespace CMS_CORE.Siemens return NO_ERROR; } + //Set the Nc Active Page of the NC + public override CmsError NC_SetScreenVisible(SCREEN_PAGE screen) + { + Console.WriteLine(Infrastructure.CurrentActiveArea); + string area = ConvertStepToSiemensScreen(screen); + if(!string.IsNullOrEmpty(area) && (Infrastructure.CurrentActiveArea!= area) ) + Infrastructure.SwitchToArea(area); + return NO_ERROR; + } + + + #endregion High level methods /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -3604,6 +3617,22 @@ namespace CMS_CORE.Siemens // } //} + + + private string ConvertStepToSiemensScreen(SCREEN_PAGE page) + { + switch (page) + { + case SCREEN_PAGE.Siemens_Machine: return "AreaMachine"; + case SCREEN_PAGE.Siemens_Parameter: return "AreaParameter"; + case SCREEN_PAGE.Siemens_Program: return "AreaProgramEdit"; + case SCREEN_PAGE.Siemens_ProgramManager: return "AreaProgramManager"; + case SCREEN_PAGE.Siemens_Setup: return "AreaStartup"; + case SCREEN_PAGE.Siemens_Diagnostics: return "AreaDiagnosis"; + default: return ""; + } + } + #endregion Subordinate Private Functions ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////