diff --git a/AgentBin/simulator/CMS_DEMO.xml b/AgentBin/simulator/CMS_DEMO.xml index 68f78f7..7710982 100644 --- a/AgentBin/simulator/CMS_DEMO.xml +++ b/AgentBin/simulator/CMS_DEMO.xml @@ -11,22 +11,24 @@ - - - - + + - + + - - + + - + + + @@ -39,12 +41,18 @@ + + + + - + + + @@ -57,12 +65,18 @@ + + + + - + + + @@ -75,11 +89,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + - @@ -105,20 +146,20 @@ --> - + - - - - - - - - - - - - + + + + + + + + + + + + - + - - - - - - - - - - - - + + + + + + + + + + + + + + + + @@ -194,17 +239,27 @@ - - - - - - - - - + + + + + + + + + + + + + + + + + + + @@ -214,7 +269,7 @@ - + + diff --git a/MTC_Sim/.vs/MTC_Sim/v14/.suo b/MTC_Sim/.vs/MTC_Sim/v14/.suo index 6ec97de..1c65711 100644 Binary files a/MTC_Sim/.vs/MTC_Sim/v14/.suo and b/MTC_Sim/.vs/MTC_Sim/v14/.suo differ diff --git a/MTC_Sim/MTC_Sim.sln b/MTC_Sim/MTC_Sim.sln index 65c7ee7..856505d 100644 --- a/MTC_Sim/MTC_Sim.sln +++ b/MTC_Sim/MTC_Sim.sln @@ -14,6 +14,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ..\AgentBin\simulator\CMS_DEMO.xml = ..\AgentBin\simulator\CMS_DEMO.xml EndProjectSection EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CMSCncLib", "CMSCncLib\CMSCncLib.vbproj", "{2D769FFD-1122-4276-A115-29246E6D23C5}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -32,6 +34,10 @@ Global {D8D08DBE-B511-4DE0-B5A9-563EBFC60C4F}.Debug|Any CPU.Build.0 = Debug|Any CPU {D8D08DBE-B511-4DE0-B5A9-563EBFC60C4F}.Release|Any CPU.ActiveCfg = Release|Any CPU {D8D08DBE-B511-4DE0-B5A9-563EBFC60C4F}.Release|Any CPU.Build.0 = Release|Any CPU + {2D769FFD-1122-4276-A115-29246E6D23C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2D769FFD-1122-4276-A115-29246E6D23C5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2D769FFD-1122-4276-A115-29246E6D23C5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2D769FFD-1122-4276-A115-29246E6D23C5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/MTC_Sim/MTC_Sim/AdapterFanuc.cs b/MTC_Sim/MTC_Sim/AdapterFanuc.cs index b0e13e2..ac0591f 100644 --- a/MTC_Sim/MTC_Sim/AdapterFanuc.cs +++ b/MTC_Sim/MTC_Sim/AdapterFanuc.cs @@ -3,11 +3,16 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using CMSCncLib.CNC; namespace MTC_Sim { public class AdapterFanuc : AdapterGeneric { + protected FANUC FANUC_ref; + + protected StatusFlag CurrStatus; + /// /// estende l'init della classe base... /// @@ -15,7 +20,17 @@ namespace MTC_Sim /// public AdapterFanuc(CMS_MachineSim caller, AdapterConf adpConf) : base(caller, adpConf) { + Runtime.CreateNC(); + FANUC_ref = (FANUC)Runtime.NC; + + string szStatusConnection = ""; + FANUC_ref.Connect(ref szStatusConnection); + + //CMSCncLib.App.Runtime.CreateRuntime(); + + //Runtime.NC.Initialize(); + //Config.Settings.Settings.TypeNC = CNC.NcType.FANUC; } public override void getCurrProgramData() @@ -23,5 +38,21 @@ namespace MTC_Sim // serve?!? base.getCurrProgramData(); } + + public override void getCurrMode() + { + base.getCurrMode(); + + byte[] status = new byte[8]; + + + // se non sono connesso esco + if (!FANUC_ref.Connected) return; + + // hard coded: leggo 8 word dalla memoria 3450--> 3457 + FANUC_ref.F_RW_Byte(R, FANUC.MemType.D, 3450, ref status); + + + } } } diff --git a/MTC_Sim/MTC_Sim/AdapterGeneric.cs b/MTC_Sim/MTC_Sim/AdapterGeneric.cs index 1e5b8a0..f849773 100644 --- a/MTC_Sim/MTC_Sim/AdapterGeneric.cs +++ b/MTC_Sim/MTC_Sim/AdapterGeneric.cs @@ -420,6 +420,10 @@ namespace MTC_Sim public class AdapterGeneric { + public bool R = false; + public bool W = true; + + /// /// adapter globale /// @@ -441,6 +445,10 @@ namespace MTC_Sim /// Status flag /// public StatusFlag STATUS_FLAG = 0; + /// + /// Variabili stato macchina principali + /// + public StFlag8 ST_MACCH = 0; public List codaM = new List(); diff --git a/MTC_Sim/MTC_Sim/Appunti.txt b/MTC_Sim/MTC_Sim/Appunti.txt index a0d38d5..adaa953 100644 --- a/MTC_Sim/MTC_Sim/Appunti.txt +++ b/MTC_Sim/MTC_Sim/Appunti.txt @@ -16,4 +16,18 @@ STROBE: gestione full PLC --> ADP e ADP --> PLC (32 bit) - STATUS: elenco di variabili semaforiche che indicano variazione status importanti (32 bit?) + status delle CLASSI di allarme (32 bit) \ No newline at end of file + STATUS: elenco di variabili semaforiche che indicano variazione status importanti (32 bit?) + status delle CLASSI di allarme (32 bit) + + + +AREE PER STATUS +- D3450 - bit 0: AUTO +- D3450 - bit 1: EDIT +- D3450 - bit 2: MDI +- D3450 - bit 3: DNC + +lettura da D3450 --> D3457 + + +ATTENZIONE: aggiungere pos memoria x status e strobe x path +Aggiungere condition (1) x ogni path e x ogni asse diff --git a/MTC_Sim/MTC_Sim/CMS_MachineSim.Designer.cs b/MTC_Sim/MTC_Sim/CMS_MachineSim.Designer.cs index 0eae262..9841ce1 100644 --- a/MTC_Sim/MTC_Sim/CMS_MachineSim.Designer.cs +++ b/MTC_Sim/MTC_Sim/CMS_MachineSim.Designer.cs @@ -132,6 +132,9 @@ this.lblCurrAdapt = new System.Windows.Forms.Label(); this.tabCtrlMain = new System.Windows.Forms.TabControl(); this.tpStatus = new System.Windows.Forms.TabPage(); + this.groupBox6 = new System.Windows.Forms.GroupBox(); + this.STATUS_FLAGS = new System.Windows.Forms.TextBox(); + this.label48 = new System.Windows.Forms.Label(); this.groupBox1 = new System.Windows.Forms.GroupBox(); this.dump = new System.Windows.Forms.Button(); this.stop = new System.Windows.Forms.Button(); @@ -195,9 +198,6 @@ this.lblCodaM = new System.Windows.Forms.Label(); this.addCodM = new System.Windows.Forms.TextBox(); this.label20 = new System.Windows.Forms.Label(); - this.groupBox6 = new System.Windows.Forms.GroupBox(); - this.STATUS_FLAGS = new System.Windows.Forms.TextBox(); - this.label48 = new System.Windows.Forms.Label(); this.groupBox4.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.PosAct)).BeginInit(); this.groupBox3.SuspendLayout(); @@ -209,6 +209,7 @@ this.menuStrip1.SuspendLayout(); this.tabCtrlMain.SuspendLayout(); this.tpStatus.SuspendLayout(); + this.groupBox6.SuspendLayout(); this.groupBox1.SuspendLayout(); this.tbConf.SuspendLayout(); this.tpSIM.SuspendLayout(); @@ -219,7 +220,6 @@ this.groupBox10.SuspendLayout(); this.groupBox8.SuspendLayout(); this.groupBox12.SuspendLayout(); - this.groupBox6.SuspendLayout(); this.SuspendLayout(); // // PlcErr_02 @@ -972,7 +972,7 @@ this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripStatusLabel1, this.MainProgrBar}); - this.statusStrip1.Location = new System.Drawing.Point(0, 725); + this.statusStrip1.Location = new System.Drawing.Point(0, 719); this.statusStrip1.Name = "statusStrip1"; this.statusStrip1.Size = new System.Drawing.Size(780, 22); this.statusStrip1.TabIndex = 59; @@ -1182,7 +1182,7 @@ this.tabCtrlMain.Location = new System.Drawing.Point(0, 50); this.tabCtrlMain.Name = "tabCtrlMain"; this.tabCtrlMain.SelectedIndex = 0; - this.tabCtrlMain.Size = new System.Drawing.Size(780, 675); + this.tabCtrlMain.Size = new System.Drawing.Size(780, 669); this.tabCtrlMain.TabIndex = 65; // // tpStatus @@ -1194,10 +1194,38 @@ this.tpStatus.Location = new System.Drawing.Point(4, 22); this.tpStatus.Name = "tpStatus"; this.tpStatus.Padding = new System.Windows.Forms.Padding(3); - this.tpStatus.Size = new System.Drawing.Size(772, 649); + this.tpStatus.Size = new System.Drawing.Size(772, 643); this.tpStatus.TabIndex = 0; this.tpStatus.Text = "STATUS"; // + // groupBox6 + // + this.groupBox6.Controls.Add(this.STATUS_FLAGS); + this.groupBox6.Controls.Add(this.label48); + this.groupBox6.Location = new System.Drawing.Point(1, 207); + this.groupBox6.Name = "groupBox6"; + this.groupBox6.Size = new System.Drawing.Size(773, 75); + this.groupBox6.TabIndex = 58; + this.groupBox6.TabStop = false; + this.groupBox6.Text = "Status & Alarms"; + // + // STATUS_FLAGS + // + this.STATUS_FLAGS.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.STATUS_FLAGS.Location = new System.Drawing.Point(85, 11); + this.STATUS_FLAGS.Name = "STATUS_FLAGS"; + this.STATUS_FLAGS.Size = new System.Drawing.Size(363, 29); + this.STATUS_FLAGS.TabIndex = 53; + // + // label48 + // + this.label48.AutoSize = true; + this.label48.Location = new System.Drawing.Point(15, 19); + this.label48.Name = "label48"; + this.label48.Size = new System.Drawing.Size(32, 13); + this.label48.TabIndex = 52; + this.label48.Text = "Flags"; + // // groupBox1 // this.groupBox1.Controls.Add(this.dump); @@ -1835,39 +1863,11 @@ this.label20.TabIndex = 52; this.label20.Text = "AddM"; // - // groupBox6 - // - this.groupBox6.Controls.Add(this.STATUS_FLAGS); - this.groupBox6.Controls.Add(this.label48); - this.groupBox6.Location = new System.Drawing.Point(1, 207); - this.groupBox6.Name = "groupBox6"; - this.groupBox6.Size = new System.Drawing.Size(773, 75); - this.groupBox6.TabIndex = 58; - this.groupBox6.TabStop = false; - this.groupBox6.Text = "Status & Alarms"; - // - // STATUS_FLAGS - // - this.STATUS_FLAGS.Font = new System.Drawing.Font("Microsoft Sans Serif", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.STATUS_FLAGS.Location = new System.Drawing.Point(85, 11); - this.STATUS_FLAGS.Name = "STATUS_FLAGS"; - this.STATUS_FLAGS.Size = new System.Drawing.Size(363, 29); - this.STATUS_FLAGS.TabIndex = 53; - // - // label48 - // - this.label48.AutoSize = true; - this.label48.Location = new System.Drawing.Point(15, 19); - this.label48.Name = "label48"; - this.label48.Size = new System.Drawing.Size(32, 13); - this.label48.TabIndex = 52; - this.label48.Text = "Flags"; - // // CMS_MachineSim // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(780, 747); + this.ClientSize = new System.Drawing.Size(780, 741); this.Controls.Add(this.tabCtrlMain); this.Controls.Add(this.lblCurrAdapt); this.Controls.Add(this.statusStrip1); @@ -1895,6 +1895,8 @@ this.menuStrip1.PerformLayout(); this.tabCtrlMain.ResumeLayout(false); this.tpStatus.ResumeLayout(false); + this.groupBox6.ResumeLayout(false); + this.groupBox6.PerformLayout(); this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); this.tbConf.ResumeLayout(false); @@ -1913,8 +1915,6 @@ this.groupBox8.PerformLayout(); this.groupBox12.ResumeLayout(false); this.groupBox12.PerformLayout(); - this.groupBox6.ResumeLayout(false); - this.groupBox6.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/MTC_Sim/MTC_Sim/CMS_MachineSim.cs b/MTC_Sim/MTC_Sim/CMS_MachineSim.cs index d0c58e8..e9b46fc 100644 --- a/MTC_Sim/MTC_Sim/CMS_MachineSim.cs +++ b/MTC_Sim/MTC_Sim/CMS_MachineSim.cs @@ -28,6 +28,9 @@ namespace MTC_Sim protected int normCount; protected int slowCount; + + + /// /// Oggetto x gestione dell'adapter GENERICO (x poter usare metodi di ognuno...) /// diff --git a/MTC_Sim/MTC_Sim/MTC_Sim.csproj b/MTC_Sim/MTC_Sim/MTC_Sim.csproj index a314929..c033791 100644 --- a/MTC_Sim/MTC_Sim/MTC_Sim.csproj +++ b/MTC_Sim/MTC_Sim/MTC_Sim.csproj @@ -103,8 +103,13 @@ {d8d08dbe-b511-4de0-b5a9-563ebfc60c4f} DotNetAdapterSDK + + {2d769ffd-1122-4276-a115-29246e6d23c5} + CMSCncLib + + diff --git a/MTC_Sim/MTC_Sim/utils.cs b/MTC_Sim/MTC_Sim/utils.cs index 9b56eb2..ccd1971 100644 --- a/MTC_Sim/MTC_Sim/utils.cs +++ b/MTC_Sim/MTC_Sim/utils.cs @@ -293,9 +293,23 @@ namespace MTC_Sim SP31 = 1 << 31 } /// + /// StFlag8: set di 8 bit (1 word) contente semaforo di variabili + /// + [Flags] + public enum StFlag8 : int + { + NONE = 0, + B0 = 1 << 0, + B1 = 1 << 1, + B2 = 1 << 2, + B3 = 1 << 3, + B4 = 1 << 4, + B5 = 1 << 5, + B6 = 1 << 6, + B7 = 1 << 7 + } + /// /// StatusFlag: contiene il set di semafori/flag x status + allarmi (x classi) - /// - /// rif: http://stackoverflow.com/questions/17209054/parse-bits-in-a-byte-to-enum /// [Flags] public enum StatusFlag : int