Completata gestione lettura INI file x parametri IOB
This commit is contained in:
+12
-12
@@ -572,18 +572,18 @@ namespace IOB_UT
|
||||
|
||||
public enum tipoAdapter
|
||||
{
|
||||
/// <summary>
|
||||
/// Adapter DB
|
||||
/// </summary>
|
||||
DB,
|
||||
///// <summary>
|
||||
///// Adapter DB
|
||||
///// </summary>
|
||||
//DB,
|
||||
/// <summary>
|
||||
/// Adapter generico/demo
|
||||
/// </summary>
|
||||
DEMO,
|
||||
/// <summary>
|
||||
/// Adapter ESAGV (SCM)
|
||||
/// </summary>
|
||||
ESAGV,
|
||||
///// <summary>
|
||||
///// Adapter ESAGV (SCM)
|
||||
///// </summary>
|
||||
//ESAGV,
|
||||
/// <summary>
|
||||
/// adapter FANUC (CMS)
|
||||
/// </summary>
|
||||
@@ -592,10 +592,10 @@ namespace IOB_UT
|
||||
/// Adapter non specificato
|
||||
/// </summary>
|
||||
ND,
|
||||
/// <summary>
|
||||
/// Adapter OSAI
|
||||
/// </summary>
|
||||
OSAI,
|
||||
///// <summary>
|
||||
///// Adapter OSAI
|
||||
///// </summary>
|
||||
//OSAI,
|
||||
/// <summary>
|
||||
/// Adapter SIEMENS (CMS)
|
||||
/// </summary>
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
</startup>
|
||||
<appSettings>
|
||||
<add key="appName" value="IOB-WIN"/>
|
||||
<add key ="ipPLC" value="192.168.157.2" />
|
||||
<!--gestione TIMERS e periodi multipli x thread lenti-->
|
||||
<add key="startTimerMs" value="250"/>
|
||||
<!-- ciclo corto x invio a server: 5ms-->
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
[IOB]
|
||||
CNC_TYPE=FANUC
|
||||
;Configurazione IOB-WIN
|
||||
[IOB]
|
||||
CNCTYPE=FANUC
|
||||
|
||||
[CNC]
|
||||
IP=127.0.0.1
|
||||
PORT=8193
|
||||
|
||||
[MEMORY]
|
||||
BIT_RED=Y8.4
|
||||
BIT_YELLOW=Y8.5
|
||||
BIT_GREEN=Y8.6
|
||||
BITRED=Y8.4
|
||||
BITYELLOW=Y8.5
|
||||
BITGREEN=Y8.6
|
||||
@@ -83,7 +83,9 @@
|
||||
<Content Include="NLog.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Include="DATA\CONF\IOB.ini" />
|
||||
<None Include="DATA\CONF\IOB.ini">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="NLog.xsd">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
|
||||
Generated
+25
-9
@@ -38,9 +38,10 @@
|
||||
this.lblStatus = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.FileTSMI = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.lOADADAPTERCONFToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mLoadConf = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
|
||||
this.trayMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.lblCurrIOB = new System.Windows.Forms.Label();
|
||||
this.statusStrip1.SuspendLayout();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
@@ -104,18 +105,19 @@
|
||||
// FileTSMI
|
||||
//
|
||||
this.FileTSMI.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.lOADADAPTERCONFToolStripMenuItem});
|
||||
this.mLoadConf});
|
||||
this.FileTSMI.Name = "FileTSMI";
|
||||
this.FileTSMI.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.F)));
|
||||
this.FileTSMI.Size = new System.Drawing.Size(47, 24);
|
||||
this.FileTSMI.Text = "&FILE";
|
||||
//
|
||||
// lOADADAPTERCONFToolStripMenuItem
|
||||
// mLoadConf
|
||||
//
|
||||
this.lOADADAPTERCONFToolStripMenuItem.Name = "lOADADAPTERCONFToolStripMenuItem";
|
||||
this.lOADADAPTERCONFToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.L)));
|
||||
this.lOADADAPTERCONFToolStripMenuItem.Size = new System.Drawing.Size(282, 26);
|
||||
this.lOADADAPTERCONFToolStripMenuItem.Text = "LOAD ADAPTER CONF";
|
||||
this.mLoadConf.Name = "mLoadConf";
|
||||
this.mLoadConf.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.L)));
|
||||
this.mLoadConf.Size = new System.Drawing.Size(214, 26);
|
||||
this.mLoadConf.Text = "LOAD CONF";
|
||||
this.mLoadConf.Click += new System.EventHandler(this.mLoadConf_Click);
|
||||
//
|
||||
// notifyIcon1
|
||||
//
|
||||
@@ -128,14 +130,27 @@
|
||||
//
|
||||
this.trayMenu.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||
this.trayMenu.Name = "trayMenu";
|
||||
this.trayMenu.Size = new System.Drawing.Size(176, 32);
|
||||
this.trayMenu.Size = new System.Drawing.Size(61, 4);
|
||||
this.trayMenu.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.trayMenu_ItemClicked);
|
||||
//
|
||||
// lblCurrIOB
|
||||
//
|
||||
this.lblCurrIOB.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.lblCurrIOB.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lblCurrIOB.Location = new System.Drawing.Point(0, 28);
|
||||
this.lblCurrIOB.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.lblCurrIOB.Name = "lblCurrIOB";
|
||||
this.lblCurrIOB.Size = new System.Drawing.Size(643, 32);
|
||||
this.lblCurrIOB.TabIndex = 65;
|
||||
this.lblCurrIOB.Text = "IOB loaded: N.A.";
|
||||
this.lblCurrIOB.TextAlign = System.Drawing.ContentAlignment.TopCenter;
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(643, 468);
|
||||
this.Controls.Add(this.lblCurrIOB);
|
||||
this.Controls.Add(this.statusStrip1);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
@@ -166,6 +181,7 @@
|
||||
private System.Windows.Forms.ToolStripStatusLabel lblComStats;
|
||||
private System.Windows.Forms.ToolStripStatusLabel lblStatus;
|
||||
private System.Windows.Forms.ToolStripMenuItem FileTSMI;
|
||||
private System.Windows.Forms.ToolStripMenuItem lOADADAPTERCONFToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem mLoadConf;
|
||||
private System.Windows.Forms.Label lblCurrIOB;
|
||||
}
|
||||
}
|
||||
+158
-6
@@ -44,7 +44,7 @@ namespace IOB_WIN
|
||||
/// <summary>
|
||||
/// timer base in avvio
|
||||
/// </summary>
|
||||
protected int startTimerMs = 250;
|
||||
protected int startTimerMs = 250;
|
||||
/// <summary>
|
||||
/// ultimo tentativo riavvio...
|
||||
/// </summary>
|
||||
@@ -124,6 +124,9 @@ namespace IOB_WIN
|
||||
|
||||
#region gestione form e visibilità
|
||||
|
||||
/// <summary>
|
||||
/// Avvio MainForm
|
||||
/// </summary>
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -179,8 +182,8 @@ namespace IOB_WIN
|
||||
tipoScelto = tipoAdapter.ND;
|
||||
#if false
|
||||
adpConf = new AdapterConf();
|
||||
loadAdapterType();
|
||||
#endif
|
||||
loadAdapterType();
|
||||
displayTaskAndWait("Waiting for config file selection");
|
||||
}
|
||||
|
||||
@@ -201,16 +204,24 @@ namespace IOB_WIN
|
||||
WindowState = FormWindowState.Minimized;
|
||||
}
|
||||
displayTaskAndWait("Minimized");
|
||||
}
|
||||
}
|
||||
|
||||
displayTaskAndWait("Main Form OK");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fase chiusura Form
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
closeAdapter();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mostrata form
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void MainForm_Shown(object sender, EventArgs e)
|
||||
{
|
||||
// avvio minimizzato se richiesto
|
||||
@@ -221,11 +232,20 @@ namespace IOB_WIN
|
||||
}
|
||||
displayTaskAndWait("Main Form SHOWN");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// COmpletato resize form
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void MainForm_Resize(object sender, EventArgs e)
|
||||
{
|
||||
checkFormVisibility();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region gestione tray
|
||||
|
||||
/// <summary>
|
||||
/// crea menù tray x applicazione
|
||||
/// </summary>
|
||||
@@ -318,6 +338,14 @@ namespace IOB_WIN
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region gestione metodi specifici FORM
|
||||
|
||||
/// <summary>
|
||||
/// Chiusura adapter
|
||||
/// </summary>
|
||||
private void closeAdapter()
|
||||
{
|
||||
fermaTutto(true, false);
|
||||
@@ -348,7 +376,131 @@ namespace IOB_WIN
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Carica file ini della configurazione richiesta
|
||||
/// </summary>
|
||||
/// <param name="iniConfFile"></param>
|
||||
private void loadIniFile(string iniConfFile)
|
||||
{
|
||||
displayTaskAndWait(string.Format("Loading iniConfFile: {0}", iniConfFile));
|
||||
|
||||
IniFile fIni = new IniFile(iniConfFile);
|
||||
|
||||
tipoScelto = (tipoAdapter)Enum.Parse(typeof(tipoAdapter), fIni.ReadString("IOB", "CNCTYPE", "DEMO"));
|
||||
string IP = fIni.ReadString("CNC", "IP", "ND");
|
||||
string PORT = fIni.ReadString("CNC", "PORT", "ND");
|
||||
lblCurrIOB.Text= string.Format("CNC {0} ({1}:{2})", tipoScelto,IP, PORT);
|
||||
#if false
|
||||
// Read the configuration object from a file
|
||||
adpConf = AdapterConf.Deserialize(iniConfFile);
|
||||
|
||||
// indico quale sia il tipo di adapter
|
||||
tipoScelto = adpConf.TipoAdapt;
|
||||
#endif
|
||||
loadAdapterType();
|
||||
#if false
|
||||
// carico file XML in web browser...
|
||||
wbXmlConf.DocumentText = AdapterConf.rawXml(iniConfFile);
|
||||
displayTaskAndWait("XML loaded");
|
||||
|
||||
#endif
|
||||
// avvio macchina con adapter specificato...
|
||||
if (utils.CRB("autoStartOnLoad"))
|
||||
{
|
||||
displayTaskAndWait("Auto Starting...");
|
||||
#if false
|
||||
// avvio!
|
||||
avviaAdapter();
|
||||
#endif
|
||||
displayTaskAndWait("Auto Started!");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void mLoadConf_Click(object sender, EventArgs e)
|
||||
{
|
||||
// mostro selettore file x leggere adapter..
|
||||
OpenFileDialog openFileDial = new OpenFileDialog();
|
||||
|
||||
// directory iniziale
|
||||
openFileDial.InitialDirectory = utils.confDir; // string.Format(@"{0}\{1}", Application.StartupPath, utils.CRS("dataConfPath"));
|
||||
// Set filter options and filter index.
|
||||
openFileDial.Filter = "INI Files (.ini)|*.ini|All Files (*.*)|*.*";
|
||||
openFileDial.FilterIndex = 1;
|
||||
// altre opzioni
|
||||
openFileDial.Multiselect = false;
|
||||
|
||||
// Call the ShowDialog method to show the dialog box.
|
||||
DialogResult userClickedOK = openFileDial.ShowDialog();
|
||||
|
||||
// Process input if the user clicked OK.
|
||||
if (userClickedOK == DialogResult.OK)
|
||||
{
|
||||
string iniConfFile = openFileDial.FileName;
|
||||
loadIniFile(iniConfFile);
|
||||
lg.Info("INI LOADED");
|
||||
#if false
|
||||
loadPersistLayer(defPersLayerFile);
|
||||
lg.Info("PersLayerFile READ");
|
||||
agObj.loadPersData();
|
||||
lg.Info("PersLayerFile LOADED");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// carica adapter richiesto
|
||||
/// </summary>
|
||||
private void loadAdapterType()
|
||||
{
|
||||
//switch (tipoScelto)
|
||||
//{
|
||||
// case tipoAdapter.DEMO:
|
||||
// agObj = new AdapterDemo(this, adpConf);
|
||||
// EnableTab(tabCtrlMain.TabPages[1], true);
|
||||
// EnableTab(tabCtrlMain.TabPages[2], true);
|
||||
// start.Enabled = true;
|
||||
// break;
|
||||
// case tipoAdapter.ESAGV:
|
||||
// agObj = new AdapterESA(this, adpConf);
|
||||
// EnableTab(tabCtrlMain.TabPages[1], true);
|
||||
// EnableTab(tabCtrlMain.TabPages[2], false);
|
||||
// start.Enabled = true;
|
||||
// break;
|
||||
// case tipoAdapter.FANUC:
|
||||
// agObj = new AdapterFanuc(this, adpConf);
|
||||
// EnableTab(tabCtrlMain.TabPages[1], true);
|
||||
// EnableTab(tabCtrlMain.TabPages[2], false);
|
||||
// start.Enabled = true;
|
||||
// break;
|
||||
// case tipoAdapter.OSAI:
|
||||
// agObj = new AdapterOsai(this, adpConf);
|
||||
// EnableTab(tabCtrlMain.TabPages[1], true);
|
||||
// EnableTab(tabCtrlMain.TabPages[2], false);
|
||||
// start.Enabled = true;
|
||||
// break;
|
||||
// case tipoAdapter.SIEMENS:
|
||||
// agObj = new AdapterSiemens(this, adpConf);
|
||||
// EnableTab(tabCtrlMain.TabPages[1], true);
|
||||
// EnableTab(tabCtrlMain.TabPages[2], false);
|
||||
// start.Enabled = true;
|
||||
// break;
|
||||
// case tipoAdapter.ND:
|
||||
// default:
|
||||
// agObj = new AdapterDemo(this, adpConf);
|
||||
// EnableTab(tabCtrlMain.TabPages[1], false);
|
||||
// EnableTab(tabCtrlMain.TabPages[2], false);
|
||||
// start.Enabled = false;
|
||||
// break;
|
||||
//}
|
||||
//lblCurrAdapt.Text = string.Format("Adapter loaded: {0}", tipoScelto.ToString().ToUpper());
|
||||
|
||||
//// carico i default values su interfaccia
|
||||
//setDefaults();
|
||||
|
||||
displayTaskAndWait(string.Format("Caricata conf per adapter {0}", tipoScelto));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user