diff --git a/CMS_CORE_Application/CMS_CORE_Application.csproj b/CMS_CORE_Application/CMS_CORE_Application.csproj
index edc48af..33ddebe 100644
--- a/CMS_CORE_Application/CMS_CORE_Application.csproj
+++ b/CMS_CORE_Application/CMS_CORE_Application.csproj
@@ -121,8 +121,6 @@
-
-
Form1.cs
diff --git a/CMS_CORE_Application/Form1.Designer.cs b/CMS_CORE_Application/Form1.Designer.cs
index 53c81ee..725a4d9 100644
--- a/CMS_CORE_Application/Form1.Designer.cs
+++ b/CMS_CORE_Application/Form1.Designer.cs
@@ -30,10 +30,6 @@
{
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();
this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
this.Disconnect = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
@@ -83,7 +79,6 @@
this.label7 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.Error = new System.Windows.Forms.TextBox();
- this.button1 = new System.Windows.Forms.Button();
this.panel1.SuspendLayout();
this.tableLayoutPanel3.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout();
@@ -118,11 +113,6 @@
| 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);
- this.panel1.Controls.Add(this.readFileBtn);
this.panel1.Controls.Add(this.tableLayoutPanel3);
this.panel1.Controls.Add(this.label3);
this.panel1.Controls.Add(this.label2);
@@ -135,43 +125,6 @@
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);
- this.NetworkReadButton.Name = "NetworkReadButton";
- this.NetworkReadButton.Size = new System.Drawing.Size(75, 23);
- this.NetworkReadButton.TabIndex = 9;
- this.NetworkReadButton.Text = "Leggi rete";
- this.NetworkReadButton.UseVisualStyleBackColor = true;
- this.NetworkReadButton.Click += new System.EventHandler(this.NetworkReadButton_Click);
- //
- // writeFileBtn
- //
- this.writeFileBtn.Location = new System.Drawing.Point(102, 13);
- this.writeFileBtn.Name = "writeFileBtn";
- this.writeFileBtn.Size = new System.Drawing.Size(75, 23);
- this.writeFileBtn.TabIndex = 8;
- this.writeFileBtn.Text = "scrivi";
- this.writeFileBtn.UseVisualStyleBackColor = true;
- this.writeFileBtn.Click += new System.EventHandler(this.writeFileBtn_Click);
- //
- // readFileBtn
- //
- this.readFileBtn.Location = new System.Drawing.Point(16, 13);
- this.readFileBtn.Name = "readFileBtn";
- this.readFileBtn.Size = new System.Drawing.Size(75, 23);
- this.readFileBtn.TabIndex = 7;
- this.readFileBtn.Text = "leggi";
- this.readFileBtn.UseVisualStyleBackColor = true;
- this.readFileBtn.Click += new System.EventHandler(this.readFileBtn_Click);
- //
// tableLayoutPanel3
//
this.tableLayoutPanel3.ColumnCount = 2;
@@ -403,7 +356,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, 294F));
+ this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 295F));
this.tableLayoutPanel1.Controls.Add(this.groupBox2, 1, 0);
this.tableLayoutPanel1.Controls.Add(this.groupBox1, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.groupBox4, 2, 0);
@@ -424,7 +377,7 @@
this.groupBox2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.groupBox2.Location = new System.Drawing.Point(159, 3);
this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(146, 265);
+ this.groupBox2.Size = new System.Drawing.Size(145, 265);
this.groupBox2.TabIndex = 28;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Plc";
@@ -438,7 +391,7 @@
this.TXTMsg.Multiline = true;
this.TXTMsg.Name = "TXTMsg";
this.TXTMsg.ReadOnly = true;
- this.TXTMsg.Size = new System.Drawing.Size(135, 238);
+ this.TXTMsg.Size = new System.Drawing.Size(134, 238);
this.TXTMsg.TabIndex = 18;
//
// groupBox1
@@ -473,9 +426,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(311, 3);
+ this.groupBox4.Location = new System.Drawing.Point(310, 3);
this.groupBox4.Name = "groupBox4";
- this.groupBox4.Size = new System.Drawing.Size(289, 265);
+ this.groupBox4.Size = new System.Drawing.Size(290, 265);
this.groupBox4.TabIndex = 29;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "Path";
@@ -489,7 +442,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(276, 238);
+ this.tabControl1.Size = new System.Drawing.Size(277, 238);
this.tabControl1.TabIndex = 0;
//
// tabPage1
@@ -498,7 +451,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(268, 212);
+ this.tabPage1.Size = new System.Drawing.Size(269, 212);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "Path 1";
this.tabPage1.UseVisualStyleBackColor = true;
@@ -512,7 +465,7 @@
this.TXTAlm.Multiline = true;
this.TXTAlm.Name = "TXTAlm";
this.TXTAlm.ReadOnly = true;
- this.TXTAlm.Size = new System.Drawing.Size(256, 203);
+ this.TXTAlm.Size = new System.Drawing.Size(257, 203);
this.TXTAlm.TabIndex = 18;
//
// groupBox3
@@ -726,16 +679,6 @@
this.Error.Size = new System.Drawing.Size(462, 20);
this.Error.TabIndex = 27;
//
- // button1
- //
- 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
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -829,11 +772,6 @@
private System.Windows.Forms.Label label12;
private System.Windows.Forms.TextBox totalTimesTXT;
private System.Windows.Forms.Label label13;
- private System.Windows.Forms.Button writeFileBtn;
- 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 66474f3..ef69cb8 100644
--- a/CMS_CORE_Application/Form1.cs
+++ b/CMS_CORE_Application/Form1.cs
@@ -1,5 +1,4 @@
-using CMS_CORE_Application.ToolDatabase;
-using CMS_CORE_Library;
+using CMS_CORE_Library;
using CMS_CORE_Library.Demo;
using CMS_CORE_Library.Fanuc;
using CMS_CORE_Library.Models;
@@ -12,7 +11,6 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
-using static CMS_CORE_Application.ToolDatabase.ToolModels;
using static CMS_CORE_Library.Models.DataStructures;
namespace CMS_CORE_Application
@@ -24,7 +22,6 @@ namespace CMS_CORE_Application
private static string NCIp;
private static ushort NCPort;
private Thread t;
- private Thread toolThread;
public Form1()
{
@@ -38,7 +35,6 @@ namespace CMS_CORE_Application
private void connectDemo_Click(object sender, EventArgs e)
{
t = new Thread(new ThreadStart(ReadBasicData));
- toolThread = new Thread(new ThreadStart(ChangeTool));
if (NcCombo.SelectedItem == null)
return;
@@ -52,7 +48,6 @@ namespace CMS_CORE_Application
Connect.Enabled = false;
Disconnect.Enabled = true;
t.Start();
- toolThread.Start();
}
}
@@ -135,24 +130,22 @@ namespace CMS_CORE_Application
SetError(Lines, cmsError);
}
List axes = new List();
+
////////////// SPEED TEST
Stopwatch st = new Stopwatch();
sw.Restart();
-
- List p = new List();
- cmsError = N.FILES_RGetFileList("", ref p);
-
-
- ActiveProgramDataModel prg = new ActiveProgramDataModel();
-
-
- cmsError = N.FILES_WSetActiveProgram(1, "//CNC_MEM/USER/PATH1/Nuovo", ref prg);
- cmsError = N.FILES_RActiveProgramData(1, ref prg);
+
+ List b = new List();
+ cmsError = N.PROC_RActiveAlarms(1, ref b);
+ cmsError = N.PROC_RActiveAlarms(2, ref b);
+ cmsError = N.PROC_RActiveAlarms(3, ref b);
+ cmsError = N.PROC_RActiveAlarms(4, ref b);
+ cmsError = N.PROC_RActiveAlarms(5, ref b);
+ cmsError = N.PROC_RActiveAlarms(6, ref b);
Console.WriteLine("ICON" + sw.ElapsedMilliseconds);
sw.Stop();
-
-
+
if (!this.IsDisposed && this.InvokeRequired)
{
this.Invoke((ThreadStart)delegate ()
@@ -187,112 +180,6 @@ namespace CMS_CORE_Application
}
}
- public void ChangeTool()
- {
- // if (NCType != "Fanuc")
- return;
- Nc ncFanuc = SetNcByType();
-
- ToolModel toola = RicercaPerManina(1);
-
- CmsError cmsError = ncFanuc.NC_Connect();
- byte id = 0;
- Stopwatch stopwatch = new Stopwatch();
- int times = 0;
- long time = 0;
- while (true)
- {
- //id = 12;
- //ncFanuc.MEM_RWByte(Nc.W, 0, Nc.MEMORY_TYPE.Fanuc_R, 9000, 1, ref id);
- //id = 0;
-
- stopwatch.Restart();
- // Read next tool area
- ncFanuc.MEM_RWByte(Nc.R, 0, Nc.MEMORY_TYPE.Fanuc_R, 9200, 1, ref id);
- // if not empty
- if (id != 0)
- {
- // Query
- ToolModel tool = RicercaPerManina(id);
- List list = new List() {
- id,
- tool.FamilyId,
- tool.ShankId,
- 2,
- 3,
- 4
- };
- // Write ids into nc memory
- ncFanuc.MEM_RWIntegerList(Nc.W, 0, Nc.MEMORY_TYPE.Fanuc_R, 9201, 0, ref list);
-
- id = 0;
- // Reset id to 0
- ncFanuc.MEM_RWByte(Nc.W, 0, Nc.MEMORY_TYPE.Fanuc_R, 9200, 1, ref id);
- stopwatch.Stop();
-
- times++;
- time += stopwatch.ElapsedMilliseconds + 100;
- // Write counters
- this.Invoke((ThreadStart)delegate ()
- {
- mediaTestDbTXT.Text = (time / times).ToString();
- lastTimeDbTXT.Text = stopwatch.ElapsedMilliseconds.ToString();
- totalTimesTXT.Text = times.ToString();
- });
- }
-
- // Wait
- Thread.Sleep(100);
- }
- }
-
- public void ChangeToolOsai()
- {
- if (NCType != "Osai")
- return;
- N = SetNcByType();
- ToolModel toola = RicercaPerManina(1);
-
- CmsError cmsError = N.NC_Connect();
- byte id = 0;
- Stopwatch stopwatch = new Stopwatch();
- while (true)
- {
- stopwatch.Restart();
- // Read next tool area
- N.MEM_RWByte(Nc.R, 0, Nc.MEMORY_TYPE.Fanuc_R, 8000, 1, ref id);
- // if not empty
- if (id != 0)
- {
- ToolModel tool = RicercaPerManina(id);
- List list = new List() { id, tool.FamilyId, tool.ShankId };
- N.MEM_RWIntegerList(Nc.W, 0, Nc.MEMORY_TYPE.Osai_GW, 8001, 0, ref list);
-
- id = 0;
- N.MEM_RWByte(Nc.W, 0, Nc.MEMORY_TYPE.Osai_GW, 8000, 1, ref id);
- stopwatch.Stop();
-
- this.Invoke((ThreadStart)delegate ()
- {
- mediaTestDbTXT.Text = stopwatch.ElapsedMilliseconds.ToString();
- });
- }
- }
- }
-
- private ToolModel RicercaPerManina(int maninaId)
- {
- ToolDatabaseContext dbCtx = new ToolDatabaseContext();
- int idManina = Convert.ToInt32(maninaId);
- // Find Tool by manina id
- ToolModel tools = dbCtx
- .Shanks
- .Where(x => x.ManinaId == idManina)
- .Join(dbCtx.Tools, m => m.ShankId, u => u.ShankId, (m, u) => u)
- .FirstOrDefault();
- return tools;
- }
-
private void SetError(List Lines, CmsError cmsError)
{
if (!this.IsDisposed && this.InvokeRequired)
@@ -358,6 +245,8 @@ namespace CMS_CORE_Application
{
if (t != null)
t.Abort();
+
+ N.NC_Disconnect();
}
private void Disconnect_Click(object sender, EventArgs e)
@@ -365,8 +254,6 @@ namespace CMS_CORE_Application
N.NC_Disconnect();
if (t != null)
t.Abort();
- //if (toolThread != null)
- // toolThread.Abort();
TXTPath1.Text = "";
TXTStat1.Text = "";
@@ -385,37 +272,6 @@ namespace CMS_CORE_Application
Disconnect.Enabled = false;
}
- private void writeFileBtn_Click(object sender, EventArgs e)
- {
- List obj = new List()
- {
- new NcToolModel() { ToolId = 22, FamilyId = 1, OffsetId1 = 1, OffsetId2 = 2, OffsetId3 = 3, OffsetLength = 4, ResidualLife = 5, ResidualRevive = 6, ShankId = 7 },
- new NcToolModel() { ToolId = 22, FamilyId = 1, OffsetId1 = 1, OffsetId2 = 2, OffsetId3 = 3, OffsetLength = 4, ResidualLife = 5, ResidualRevive = 6, ShankId = 7 }
- };
- CmsError cms = N.TOOLS_WUpdateTools(obj);
- if (cms.IsError())
- {
- MessageBox.Show(cms.localizationKey);
- }
- }
-
- private void readFileBtn_Click(object sender, EventArgs e)
- {
- using (FileStream fileStream = new FileStream("C:\\test.csv", FileMode.OpenOrCreate))
- {
- CmsError cms = N.FILES_RProgramToFile(pathTextBox.Text, fileStream);
- if (cms.IsError())
- {
- MessageBox.Show(cms.localizationKey);
- }
- else
- {
- string text = File.ReadAllText("C:\\test.csv");
- MessageBox.Show(text);
- }
- }
- }
-
private void NetworkReadButton_Click(object sender, EventArgs e)
{
List obj = new List()
diff --git a/CMS_CORE_Application/ToolDatabase/ToolDatabaseContext.cs b/CMS_CORE_Application/ToolDatabase/ToolDatabaseContext.cs
deleted file mode 100644
index 7c72eb7..0000000
--- a/CMS_CORE_Application/ToolDatabase/ToolDatabaseContext.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using MySql.Data.Entity;
-using System.Data.Entity;
-using static CMS_CORE_Application.ToolDatabase.ToolModels;
-
-namespace CMS_CORE_Application.ToolDatabase
-{
- [DbConfigurationType(typeof(MySqlEFConfiguration))]
-
- public class ToolDatabaseContext : DbContext
- {
- public DbSet Tools { get; set; }
- public DbSet Shanks { get; set; }
- public DbSet Family { get; set; }
- public DbSet Manine { get; set; }
-
- public ToolDatabaseContext() : base("mySQLDatabaseConnection")
- {
-
- }
- }
-}
diff --git a/CMS_CORE_Application/ToolDatabase/ToolModels.cs b/CMS_CORE_Application/ToolDatabase/ToolModels.cs
deleted file mode 100644
index d8248ea..0000000
--- a/CMS_CORE_Application/ToolDatabase/ToolModels.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.ComponentModel.DataAnnotations.Schema;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace CMS_CORE_Application.ToolDatabase
-{
- public class ToolModels
- {
- [Table("tool")]
-
- public class ToolModel
- {
- [Key]
- [Column("id")]
- public int ToolId { get; set; }
- [Column("broken")]
- public bool Broken { get; set; }
- [Column("shank")]
- public int ShankId { get; set; }
- [ForeignKey("ShankId")]
- public DbShankModel Shank { get; set; }
- [Column("family")]
- public int FamilyId { get; set; }
- [ForeignKey("FamilyId")]
- public DbFamilyModel Family { get; set; }
- }
-
- [Table("shank")]
- public class DbShankModel
- {
- [Key]
- [Column("id")]
- public int ShankId { get; set; }
- [Column("manina")]
- public int? ManinaId { get; set; }
- [ForeignKey("ManinaId")]
- public DbFamilyModel Manina { get; set; }
- [Column("tablet_id")]
- public int TabletId { get; set; }
- }
-
- [Table("family")]
- public class DbFamilyModel
- {
- [Key]
- [Column("id")]
- public int FamilyId { get; set; }
- [Column("gamma")]
- public int Gamma { get; set; }
- }
-
- [Table("manina")]
- public class ManinaModello
- {
- [Key]
- [Column("id")]
- public int IdManina { get; set; }
- [Column("store")]
- public int Store { get; set; }
-
- }
- }
-}
diff --git a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs
index 6a422ad..950a7e2 100644
--- a/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs
+++ b/CMS_CORE_Library/Fanuc/Nc_Fanuc.cs
@@ -36,9 +36,9 @@ namespace CMS_CORE_Library.Fanuc
private static int MAX_OFFSET_NUM = 0;
// Paths
+ private const string NC_PROGRAM_UPLOAD_PATH = "//CNC_MEM/USER/PATH1";
private const string PLC_MESSAGE_PATH = @"C:\CMS\FANUC\";
-
-
+
// Const
private const int TOOL_OFFSET = 300;
@@ -99,6 +99,7 @@ namespace CMS_CORE_Library.Fanuc
if (nReturn != 0)
return GetNcError(nReturn);
}
+
// Read offset decimal digits
if(OFFSET_DECIMAL_DIGITS == 0)
{
@@ -325,7 +326,7 @@ namespace CMS_CORE_Library.Fanuc
//Get the NC Alarms
public override CmsError NC_RActiveAlarms(ref List alarms)
{
- //Check if the NC is Connected
+ // Check if the NC is Connected
CmsError cmsError = CheckConnection();
if (cmsError.IsError())
return cmsError;
@@ -819,15 +820,59 @@ namespace CMS_CORE_Library.Fanuc
return NO_ERROR;
}
- //Get the process Alarms
- public override CmsError PROC_RActiveAlarms(ushort procNumber, ref List Alarms)
- {
- Alarms.Clear();
+ // Get the process Alarms
+ public override CmsError PROC_RActiveAlarms(ushort procNumber, ref List alarms)
+ {
+ // Check if the NC is Connected
+ CmsError cmsError = CheckConnection();
+ if (cmsError.IsError())
+ return cmsError;
+
+ alarms.Clear();
+
+ Focas1.ODBALMMSG2 Messg = new Focas1.ODBALMMSG2();
+ short nReturn = 0;
+ short count = FANUC_MAXMSGCNC;
+
+ // Get path index
+ short pathNumber = GetHandleIndexFromPath(procNumber);
+ if (pathNumber < 0)
+ return PROC_NOT_FOUND_ERROR;
+
+ // Execute the method
+ nReturn = Focas1.cnc_rdalmmsg2(nLibHandle[pathNumber], -1, ref count, Messg);
+
+ // Throw Exception if there's an error
+ if (nReturn != 0)
+ return GetNcError(nReturn);
+
+ // Add Alarm in List
+ alarms.Clear();
+ if (count >= 1)
+ AddAlarmToList(Messg.msg1.alm_no, Messg.msg1.alm_msg.Substring(0, Messg.msg1.msg_len), pathNumber, DateTime.Now, alarms);
+ if (count >= 2)
+ AddAlarmToList(Messg.msg2.alm_no, Messg.msg2.alm_msg.Substring(0, Messg.msg2.msg_len), pathNumber, DateTime.Now, alarms);
+ if (count >= 3)
+ AddAlarmToList(Messg.msg3.alm_no, Messg.msg3.alm_msg.Substring(0, Messg.msg3.msg_len), pathNumber, DateTime.Now, alarms);
+ if (count >= 4)
+ AddAlarmToList(Messg.msg4.alm_no, Messg.msg4.alm_msg.Substring(0, Messg.msg4.msg_len), pathNumber, DateTime.Now, alarms);
+ if (count >= 5)
+ AddAlarmToList(Messg.msg5.alm_no, Messg.msg5.alm_msg.Substring(0, Messg.msg5.msg_len), pathNumber, DateTime.Now, alarms);
+ if (count >= 6)
+ AddAlarmToList(Messg.msg6.alm_no, Messg.msg6.alm_msg.Substring(0, Messg.msg6.msg_len), pathNumber, DateTime.Now, alarms);
+ if (count >= 7)
+ AddAlarmToList(Messg.msg7.alm_no, Messg.msg7.alm_msg.Substring(0, Messg.msg7.msg_len), pathNumber, DateTime.Now, alarms);
+ if (count >= 8)
+ AddAlarmToList(Messg.msg8.alm_no, Messg.msg8.alm_msg.Substring(0, Messg.msg8.msg_len), pathNumber, DateTime.Now, alarms);
+ if (count >= 9)
+ AddAlarmToList(Messg.msg9.alm_no, Messg.msg9.alm_msg.Substring(0, Messg.msg9.msg_len), pathNumber, DateTime.Now, alarms);
+ if (count >= 10)
+ AddAlarmToList(Messg.msg10.alm_no, Messg.msg10.alm_msg.Substring(0, Messg.msg10.msg_len), pathNumber, DateTime.Now, alarms);
return NO_ERROR;
}
- //Get PP Lines
+ // Get PP Lines
public override CmsError PROC_RPPLines(ushort procNumber, ref List lines)
{
//Check if the NC is Connected
@@ -874,7 +919,7 @@ namespace CMS_CORE_Library.Fanuc
return NO_ERROR;
}
- //Get Active PP Name
+ // Get Active PP Name
public override CmsError PROC_RSelectedPPName(ushort procNumber, ref string name)
{
//Check if the NC is Connected
@@ -902,7 +947,7 @@ namespace CMS_CORE_Library.Fanuc
return NO_ERROR;
}
- //Get the process status
+ // Get the process status
public override CmsError PROC_RStatus(ushort procNumber, ref PROC_STATUS Status)
{
Focas1.ODBST statusInfo = new Focas1.ODBST();
@@ -930,7 +975,7 @@ namespace CMS_CORE_Library.Fanuc
return NO_ERROR;
}
- //Get the process Mode
+ // Get the process Mode
public override CmsError PROC_RMode(ushort procNumber, ref PROC_MODE Mode)
{
Focas1.ODBST statusInfo = new Focas1.ODBST();
@@ -2163,6 +2208,16 @@ namespace CMS_CORE_Library.Fanuc
public override CmsError FILES_UploadPartProgram(string localPath, string name, ref string newFilePath)
{
+ // Open file
+ FileStream fileStream = new FileStream(localPath + "\\" + name, FileMode.Open);
+ newFilePath = NC_PROGRAM_UPLOAD_PATH + name;
+ // Transfer file on NC
+ CmsError cmsError = FILES_WProgramFromFile(newFilePath, fileStream);
+ if (cmsError.IsError())
+ return cmsError;
+
+ fileStream.Close();
+
return NO_ERROR;
}
@@ -2989,19 +3044,19 @@ namespace CMS_CORE_Library.Fanuc
return PROC_MODE.ERROR;
}
- //Get the Right Process
- private short GetHandleIndexFromPath(ushort Path)
+ // Get the Right Process
+ private short GetHandleIndexFromPath(ushort path)
{
//Check it is too big
- if (Path > Cnc_NumPath)
+ if (path > Cnc_NumPath)
return -1;
//Check it is too small
- if (Path <= 0)
+ if (path <= 0)
return -1;
//Return
- return (short)(Path - 1);
+ return (short)(path - 1);
}
//Read Static Data
@@ -3358,8 +3413,8 @@ namespace CMS_CORE_Library.Fanuc
internal static MEMORY_CELL AXIS_RESET_PROCEDURE = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, 52607, 7, 1);
- internal static MEMORY_CELL PROCESS_STATUS = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, 52581, 0, 24);
- internal static MEMORY_CELL SELECTED_PROCESS = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, 52581, 2, 24);
+ internal static MEMORY_CELL PROCESS_STATUS = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, 12000, 0, 24);
+ internal static MEMORY_CELL SELECTED_PROCESS = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, 12000, 2, 24);
internal static MEMORY_CELL SELECT_PROCESS = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, 52605, 1);
internal static MEMORY_CELL COUNTERS = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, 0, 0, 40);
diff --git a/CMS_CORE_Library/Nc.cs b/CMS_CORE_Library/Nc.cs
index 300233f..463ea10 100644
--- a/CMS_CORE_Library/Nc.cs
+++ b/CMS_CORE_Library/Nc.cs
@@ -1830,6 +1830,18 @@ namespace CMS_CORE_Library
});
}
+ internal void AddAlarmToList(int id, string message, int process, DateTime dateTime, List alarms)
+ {
+ alarms.Add(new AlarmModel()
+ {
+ Id = (uint)id,
+ Message = message,
+ IsWarning = false,
+ Process = process,
+ DateTime = dateTime
+ });
+ }
+
internal void AddAlarmToList(uint id, string message, int process, List alarms)
{
alarms.Add(new AlarmModel()
diff --git a/CMS_CORE_Library/Siemens/Nc_Siemens.cs b/CMS_CORE_Library/Siemens/Nc_Siemens.cs
index 580f3d6..120cf7b 100644
--- a/CMS_CORE_Library/Siemens/Nc_Siemens.cs
+++ b/CMS_CORE_Library/Siemens/Nc_Siemens.cs
@@ -74,7 +74,7 @@ namespace CMS_CORE_Library.Siemens
private Alarm[] SiemensAlarms;
// Tool table listeners
- private static ToolMngmntSvc SiemensToolSvc = null;
+ private ToolMngmntSvc SiemensToolSvc = null;
private static DataSvc MagazinePositionSvc = null;
private static DataSvc MagazineActionsSvc = null;
@@ -93,7 +93,7 @@ namespace CMS_CORE_Library.Siemens
private static bool LIFE_OPTION_ACTIVE;
private static bool MULTITOOL_OPTION_ACTIVE;
- private static string PlcMessagesFilePath = "C:\\Program Files (x86)\\Siemens\\MotionControl\\oem\\sinumerik\\hmi\\lng\\";
+ private const string PLC_MESSAGES_FILE_PATH = "C:\\Program Files (x86)\\Siemens\\MotionControl\\oem\\sinumerik\\hmi\\lng\\";
private const string AXES_FILE_PATH = "C:\\CMS\\axes.xml";
private SiemensEdgesConfiguration Add_Edges_Param_Config = new SiemensEdgesConfiguration();
@@ -288,7 +288,7 @@ namespace CMS_CORE_Library.Siemens
CultureInfo cultureInfo = CultureInfo.CreateSpecificCulture(language);
//Setup the path of NC alarms translations file
- filePath = PlcMessagesFilePath + "cmsalarm_" + cultureInfo.ThreeLetterWindowsLanguageName.ToUpper() + ".ts";
+ filePath = PLC_MESSAGES_FILE_PATH + "cmsalarm_" + cultureInfo.ThreeLetterWindowsLanguageName.ToUpper() + ".ts";
if (!File.Exists(filePath))
return INCORRECT_LANGUAGE_ERROR;
@@ -512,13 +512,16 @@ namespace CMS_CORE_Library.Siemens
public override CmsError PLC_RActiveMessages(ref List alarms)
{
+ bool[] statusBits;
+ int i = 0;
+ List readValues = new List();
+ CmsError cmsError;
try
{
alarms.Clear();
- List readValues = new List();
// Read on data from memory
- CmsError cmsError = MEM_RWIntegerList(R, 0,
+ cmsError = MEM_RWIntegerList(R, 0,
ALARMS_STATUS.MemType,
ALARMS_STATUS.Address,
ALARMS_STATUS.SubAddress,
@@ -526,7 +529,9 @@ namespace CMS_CORE_Library.Siemens
ref readValues);
if (cmsError.IsError())
- alarms.Clear();
+ return cmsError;
+
+ alarms.Clear();
//List readValues = new List();
@@ -542,15 +547,15 @@ namespace CMS_CORE_Library.Siemens
// return cmsError;
// Convert integer array into bit array
- bool[] statusBits = IntToBool(readValues.ToArray());
+ statusBits = IntToBool(readValues.ToArray());
- for (int i = 0; i < ALARMS_STATUS.Size * 8; i++)
+ for (i = 0; i < ALARMS_STATUS.Size * 8; i++)
{
// If alarm is active
if (statusBits[i])
{
// Calculate matching alarm byte info address
- int dataByteAddress = i * 16 + ALARMS_NUMBER;
+ int dataByteAddress = (i * 16) + ALARMS_NUMBER;
var processList = new List();
@@ -1791,13 +1796,12 @@ namespace CMS_CORE_Library.Siemens
//Setup variables
DataSvc Data = new DataSvc
{
- Timeout = TimeoutConn,
PriorityFlag = SlPriority.highPriority
};
cmsError = ConvertMemToPath(MemType, MemTable, MemIndex, 0, (bWrite) ? Value.Count : Number, 'D', out string itemString);
-
if (cmsError.IsError())
return cmsError;
+
Item item = new Item(itemString);
//Read-Write Data
@@ -2260,9 +2264,9 @@ namespace CMS_CORE_Library.Siemens
public override CmsError TOOLS_RToolsData(ref List toolTable)
{
- toolTable = new List(ToolTableData.Select(x =>
+ toolTable = new List( ToolTableData.Select(x =>
{
- // find if is loaded in magazine
+ // Find if is loaded in magazine
MountedToolModel tool = MagazineMountedTools.Where(y => y.ToolId == x.Id).FirstOrDefault();
if (tool != null)
{
@@ -3149,11 +3153,11 @@ namespace CMS_CORE_Library.Siemens
var tool = GetToolOrMultitool(tmp.ToolId);
- if (tool is ShankModel) // If multitool
- {
- occupiedIds.Add((tool as ShankModel).Id); // Add multitool id
- }
- else if (tool is SiemensToolModel) // If tool
+ //if (tool is ShankModel) // If multitool
+ //{
+ // occupiedIds.Add((tool as ShankModel).Id); // Add multitool id
+ //} else
+ if (tool is SiemensToolModel) // If tool
{
occupiedIds.Add((tool as SiemensToolModel).Id);
}
@@ -3369,7 +3373,7 @@ namespace CMS_CORE_Library.Siemens
return NO_ERROR;
}
- //Check if Memory Area is corrected
+ // Check if Memory Area is corrected
private CmsError ConvertMemToPath(MEMORY_TYPE MemoryType, int Address, int SubAddress, int SubBit, int Qty, char MemAccess, out string item)
{
char[] allowedAccess = { 'X', 'B', 'W', 'D' };
@@ -4494,21 +4498,15 @@ namespace CMS_CORE_Library.Siemens
var tool = GetToolOrMultitool(Convert.ToInt32(toolInfo.tNo));
if (tool is SiemensToolModel)
{
- // TODO remove when Siemens Library bugs have been fixed
- if (ToolIsInMultitool((int)toolInfo.tNo) != 0)
- return;
- else
- {
- // Read magazine id from memory
- DataSvc dataSvc = new DataSvc();
- Item item = new Item() { Path = string.Format("/Tool/Data/toolInMag[{0}]", (int)toolInfo.tNo) };
- // Read magazine position
- dataSvc.Read(item);
- magazineId = Convert.ToInt32(item.Value);
- item = new Item() { Path = string.Format("/Tool/Data/toolInPlace[{0}]", toolInfo.tNo) };
- dataSvc.Read(item);
- positionId = Convert.ToInt32(item.Value);
- }
+ // Read magazine id from NC
+ DataSvc dataSvc = new DataSvc();
+ Item item = new Item() { Path = string.Format("/Tool/Data/toolInMag[{0}]", (int)toolInfo.tNo) };
+ dataSvc.Read(item);
+ magazineId = Convert.ToInt32(item.Value);
+ // Read magazine position id from NC
+ item = new Item() { Path = string.Format("/Tool/Data/toolInPlace[{0}]", toolInfo.tNo) };
+ dataSvc.Read(item);
+ positionId = Convert.ToInt32(item.Value);
}
MountToolToMagazineList((int)toolInfo.tNo, magazineId, positionId);
@@ -4559,7 +4557,7 @@ namespace CMS_CORE_Library.Siemens
// Find tool by id
var tool = GetToolOrMultitool(toolId);
- if (tool is SiemensToolModel || tool is ShankModel)
+ if (tool != null)
MagazineMountedTools.Add(new MountedToolModel()
{
MagazineId = magazineId,
@@ -4718,16 +4716,16 @@ namespace CMS_CORE_Library.Siemens
private int ToolIsInMultitool(int toolId)
{
// Loop through multitools
- foreach (ShankModel multi in MultitoolsData)
- {
- if (multi.ChildsTools.Count() > 0)
- {
- // Find tool id in multitool childs
- int childIndex = multi.ChildsTools.FindIndex(x => x.Id == toolId);
- if (childIndex >= 0)
- return multi.Id;
- }
- }
+ //foreach (ShankModel multi in MultitoolsData)
+ //{
+ // if (multi.ChildsTools.Count() > 0)
+ // {
+ // // Find tool id in multitool childs
+ // int childIndex = multi.ChildsTools.FindIndex(x => x.Id == toolId);
+ // if (childIndex >= 0)
+ // return multi.Id;
+ // }
+ //}
return 0;
}
@@ -4755,11 +4753,10 @@ namespace CMS_CORE_Library.Siemens
// Check if there are enough locations
if (!isUpdate && totalNumberOfChilds + MAX_TOOLS_PER_MULTITOOL > MAX_MULTITOOLS_LOCATIONS)
return MAX_MULTITOOL_LOCATION_REACHED_ERROR;
+
return NO_ERROR;
}
-
- // ------------- TODO IMPROVE
private ShankModel CreateMultitoolFromId(int multitoolId, string[] toolsStrings)
{
SiemensEdgesConfiguration toolEdgesConfig = new SiemensEdgesConfiguration();