Per verificare il funzionamento dei driver iTools® con il framework MONO occorre creare un progetto “Windows Forms Application” con Visual Studio, quindi per facilitare la compilazione dell’applicazione sotto MONO eliminiamo i file Program.cs, Form1.Designer.cs e Form1.resx, il risultato finale è un solo file che contiene tutto il codice necessario:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace TestMonoDriver { public partial class Form1 : Form { private IToolS.Components.Communication.Clients clients1; private IToolS.Components.Communication.Client client1; private IToolS.Components.Communication.Group group1; private IToolS.Components.Communication.Variable variable1; private IToolS.Components.Communication.Variable variable2; private IToolS.Components.Communication.Variable variable3; private IToolS.Components.IOServers.IOServer ioServer1; private IToolS.Windows.Forms.Variables.VariablesWindow variablesWindow1; /// /// Required designer variable. /// private System.ComponentModel.IContainer components = null; public Form1() { InitializeComponent(); } #region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.clients1 = new IToolS.Components.Communication.Clients(this.components); this.client1 = new IToolS.Components.Communication.Client(this.components); this.group1 = new IToolS.Components.Communication.Group(this.components); this.variable1 = new IToolS.Components.Communication.Variable(this.components); this.variable2 = new IToolS.Components.Communication.Variable(this.components); this.variable3 = new IToolS.Components.Communication.Variable(this.components); this.ioServer1 = new IToolS.Components.IOServers.IOServer(this.components); this.variablesWindow1 = new IToolS.Windows.Forms.Variables.VariablesWindow(); ((System.ComponentModel.ISupportInitialize)(this.clients1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.client1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.group1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.variable1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.variable2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.variable3)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.ioServer1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.variablesWindow1)).BeginInit(); this.SuspendLayout(); // // clients1 // this.clients1.ClientsName = "clients1"; this.clients1.Items.AddRange(new IToolS.Components.Communication.Client[] { this.client1}); // // client1 // this.client1.ClientName = "client1"; this.client1.Group = this.group1; this.client1.IOServer = this.ioServer1; // // group1 // this.group1.GroupName = "group1"; this.group1.Items.AddRange(new IToolS.Components.Communication.Variable[] { this.variable1, this.variable2, this.variable3}); // // variable1 // this.variable1.Address = "0"; this.variable1.VariableName = "variable1"; // // variable2 // this.variable2.Address = "1"; this.variable2.VariableName = "variable2"; // // variable3 // this.variable3.Address = "2"; this.variable3.VariableName = "variable3"; // // ioServer1 // this.ioServer1.Name = "Simulation"; // // variablesWindow1 // this.variablesWindow1.ColumnColor = System.Drawing.SystemColors.Control; this.variablesWindow1.Dock = System.Windows.Forms.DockStyle.Fill; this.variablesWindow1.EditKeyboardConfig.Font = new System.Drawing.Font("Tahoma", 8F); this.variablesWindow1.Fields = new string[] { "VariableName", "VariableType", "Area", "Address", "Value"}; this.variablesWindow1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.variablesWindow1.Group = this.group1; this.variablesWindow1.KeyboardConfig.Font = new System.Drawing.Font("Tahoma", 8F); this.variablesWindow1.Location = new System.Drawing.Point(0, 0); this.variablesWindow1.Name = "variablesWindow1"; this.variablesWindow1.OwnerDraw = false; this.variablesWindow1.Size = new System.Drawing.Size(547, 352); this.variablesWindow1.TabIndex = 1; this.variablesWindow1.UseSheet = false; // // Form1 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(547, 352); this.Controls.Add(this.variablesWindow1); this.Name = "Form1"; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.clients1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.client1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.group1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.variable1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.variable2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.variable3)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.ioServer1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.variablesWindow1)).EndInit(); this.ResumeLayout(false); } #endregion /// /// Clean up any resources being used. /// /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } private void Form1_Load(object sender, EventArgs e) { clients1.Start(); } /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } } } |
Come si vede dal codice riportato sopra è stata creata un’applicazione che utilizza il driver iTools® ModnetMaster per leggere i registri 0, 1 e 2 dell’area Holding Register. Creato il progetto e compilato con visual studio per l’esecuzione con il Framework .NET l’applicazione può essere eseguita semplicemente con il comando:
C:\Temp\TestModoDriver\mono TestModoDriver.exe
Per la compilazione sotto MONO:
Se tutto è andato a buon fine dovrebbe comparire un’applicazione con il seguente aspetto:
La stessa applicazione possiamo eseguirla su MacOSX con il comando:
Alberto$ mono /monotest/TestModoDriver.exe