Completata bozza start/stop della FORM...
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
<!--Definizione avvio Adapter-->
|
||||
<add key="autoLoadConf" value="false"/>
|
||||
<add key="autoStartOnLoad" value="true"/>
|
||||
<add key="openDumpOnStart" value="true"/>
|
||||
<add key="openDumpOnStart" value="false"/>
|
||||
<add key="startMinimized" value="false"/>
|
||||
<add key="windowCanMax" value="true"/>
|
||||
<add key="trayClose" value="true"/>
|
||||
@@ -34,6 +34,6 @@
|
||||
<!--<add key="AlarmList" value="AlarmList.map"/>
|
||||
<add key="AlarmListCNC" value="AlarmListCNC.map"/>-->
|
||||
<add key="defaultConfFile" value="Adapter_ItemList.xml"/>
|
||||
<!--<add key="defaultPersLayerFile" value="PersistData.dat"/>-->
|
||||
<add key="defaultPersLayerFile" value="PersistData.dat"/>
|
||||
</appSettings>
|
||||
</configuration>
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
<Link>VersGen.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="IobConfiguration.cs" />
|
||||
<Compile Include="IobSiemens.cs" />
|
||||
<Compile Include="IobDemo.cs" />
|
||||
<Compile Include="IobFanuc.cs" />
|
||||
<Compile Include="IobGeneric.cs" />
|
||||
@@ -66,6 +67,10 @@
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="utils.cs" />
|
||||
<Content Include="dump\dump.c" />
|
||||
<Content Include="dump\dump.exe">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Resources\SteamWare.ico">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
@@ -87,6 +92,11 @@
|
||||
<None Include="DATA\CONF\IOB.ini">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="DATA\DAT\PersistData.dat">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="dump\build.bat" />
|
||||
<None Include="dump\dump.obj" />
|
||||
<None Include="NLog.xsd">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
|
||||
+778
-217
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using IOB_UT;
|
||||
|
||||
namespace IOB_WIN
|
||||
{
|
||||
public class IobSiemens : IobGeneric
|
||||
{
|
||||
/// <summary>
|
||||
/// estende l'init della classe base...
|
||||
/// </summary>
|
||||
/// <param name="caller"></param>
|
||||
/// <param name="adpConf"></param>
|
||||
public IobSiemens(MainForm caller, IobConfiguration IOBConf) : base(caller, IOBConf)
|
||||
{
|
||||
#if false
|
||||
// è little endian (NON serve conversione)
|
||||
hasBigEndian = false;
|
||||
|
||||
lg.Info("Start init Adapter FANUC all'IP {0}", utils.CRS("ipPLC"));
|
||||
|
||||
parentForm.commPlcActive = true;
|
||||
Runtime.CreateNC(CNC.NcType.FANUC, utils.CRS("ipPLC"));
|
||||
parentForm.commPlcActive = false;
|
||||
// inizializzo posizioni assi...
|
||||
prevPosAxis = new double[adpConf.nAxis];
|
||||
prevDirAxis = new int[adpConf.nAxis];
|
||||
|
||||
FANUC_ref = (FANUC)Runtime.NC;
|
||||
if (utils.CRB("verbose")) lg.Info("FANUC_ref da CMSCncLib");
|
||||
|
||||
// disconnetto e connetto...
|
||||
if (utils.CRB("verbose")) lg.Info("FANUC: tryDisconnect");
|
||||
tryDisconnect();
|
||||
lg.Info("FANUC: tryConnect");
|
||||
tryConnect();
|
||||
lg.Info("End init Adapter FANUC");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+113
-16
@@ -33,7 +33,7 @@
|
||||
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
|
||||
this.lblApp = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.lblVers = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.toolStripProgressBar1 = new System.Windows.Forms.ToolStripProgressBar();
|
||||
this.MainProgrBar = new System.Windows.Forms.ToolStripProgressBar();
|
||||
this.lblComStats = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.lblStatus = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
@@ -51,10 +51,17 @@
|
||||
this.start = new System.Windows.Forms.Button();
|
||||
this.port = new System.Windows.Forms.TextBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.STATUS_STRB_DW0 = new System.Windows.Forms.TextBox();
|
||||
this.lblPLC_ADP = new System.Windows.Forms.Label();
|
||||
this.gbMonitor = new System.Windows.Forms.GroupBox();
|
||||
this.lblOutMessage3 = new System.Windows.Forms.Label();
|
||||
this.lblOutMessage2 = new System.Windows.Forms.Label();
|
||||
this.lblOutMessage = new System.Windows.Forms.Label();
|
||||
this.statusStrip1.SuspendLayout();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.tableLayoutPanel1.SuspendLayout();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.gbMonitor.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// statusStrip1
|
||||
@@ -63,12 +70,12 @@
|
||||
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.lblApp,
|
||||
this.lblVers,
|
||||
this.toolStripProgressBar1,
|
||||
this.MainProgrBar,
|
||||
this.lblComStats,
|
||||
this.lblStatus});
|
||||
this.statusStrip1.Location = new System.Drawing.Point(0, 349);
|
||||
this.statusStrip1.Location = new System.Drawing.Point(0, 402);
|
||||
this.statusStrip1.Name = "statusStrip1";
|
||||
this.statusStrip1.Size = new System.Drawing.Size(706, 25);
|
||||
this.statusStrip1.Size = new System.Drawing.Size(974, 25);
|
||||
this.statusStrip1.TabIndex = 0;
|
||||
this.statusStrip1.Text = "statusStrip1";
|
||||
//
|
||||
@@ -85,10 +92,10 @@
|
||||
this.lblVers.Size = new System.Drawing.Size(18, 20);
|
||||
this.lblVers.Text = "...";
|
||||
//
|
||||
// toolStripProgressBar1
|
||||
// MainProgrBar
|
||||
//
|
||||
this.toolStripProgressBar1.Name = "toolStripProgressBar1";
|
||||
this.toolStripProgressBar1.Size = new System.Drawing.Size(100, 19);
|
||||
this.MainProgrBar.Name = "MainProgrBar";
|
||||
this.MainProgrBar.Size = new System.Drawing.Size(100, 19);
|
||||
//
|
||||
// lblComStats
|
||||
//
|
||||
@@ -109,7 +116,7 @@
|
||||
this.FileTSMI});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Size = new System.Drawing.Size(706, 28);
|
||||
this.menuStrip1.Size = new System.Drawing.Size(974, 28);
|
||||
this.menuStrip1.TabIndex = 1;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
@@ -159,7 +166,7 @@
|
||||
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||
this.tableLayoutPanel1.RowCount = 1;
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(706, 42);
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(974, 42);
|
||||
this.tableLayoutPanel1.TabIndex = 66;
|
||||
//
|
||||
// lblTopCent
|
||||
@@ -168,10 +175,10 @@
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.lblTopCent.Font = new System.Drawing.Font("Microsoft Sans Serif", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lblTopCent.Location = new System.Drawing.Point(180, 0);
|
||||
this.lblTopCent.Location = new System.Drawing.Point(247, 0);
|
||||
this.lblTopCent.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.lblTopCent.Name = "lblTopCent";
|
||||
this.lblTopCent.Size = new System.Drawing.Size(345, 42);
|
||||
this.lblTopCent.Size = new System.Drawing.Size(479, 42);
|
||||
this.lblTopCent.TabIndex = 68;
|
||||
this.lblTopCent.Text = "IOB loaded: N.A.";
|
||||
this.lblTopCent.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
@@ -182,9 +189,9 @@
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.lblTopDx.AutoSize = true;
|
||||
this.lblTopDx.Location = new System.Drawing.Point(532, 0);
|
||||
this.lblTopDx.Location = new System.Drawing.Point(733, 0);
|
||||
this.lblTopDx.Name = "lblTopDx";
|
||||
this.lblTopDx.Size = new System.Drawing.Size(171, 42);
|
||||
this.lblTopDx.Size = new System.Drawing.Size(238, 42);
|
||||
this.lblTopDx.TabIndex = 69;
|
||||
this.lblTopDx.Text = "...";
|
||||
this.lblTopDx.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
@@ -197,7 +204,7 @@
|
||||
this.lblTopSx.AutoSize = true;
|
||||
this.lblTopSx.Location = new System.Drawing.Point(3, 0);
|
||||
this.lblTopSx.Name = "lblTopSx";
|
||||
this.lblTopSx.Size = new System.Drawing.Size(170, 42);
|
||||
this.lblTopSx.Size = new System.Drawing.Size(237, 42);
|
||||
this.lblTopSx.TabIndex = 70;
|
||||
this.lblTopSx.Text = "...";
|
||||
this.lblTopSx.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
@@ -227,6 +234,7 @@
|
||||
this.dump.TabIndex = 4;
|
||||
this.dump.Text = "Show Dump";
|
||||
this.dump.UseVisualStyleBackColor = true;
|
||||
this.dump.Click += new System.EventHandler(this.dump_Click);
|
||||
//
|
||||
// stop
|
||||
//
|
||||
@@ -237,6 +245,7 @@
|
||||
this.stop.TabIndex = 3;
|
||||
this.stop.Text = "Stop";
|
||||
this.stop.UseVisualStyleBackColor = true;
|
||||
this.stop.Click += new System.EventHandler(this.stop_Click);
|
||||
//
|
||||
// start
|
||||
//
|
||||
@@ -247,6 +256,7 @@
|
||||
this.start.TabIndex = 2;
|
||||
this.start.Text = "Start";
|
||||
this.start.UseVisualStyleBackColor = true;
|
||||
this.start.Click += new System.EventHandler(this.start_Click);
|
||||
//
|
||||
// port
|
||||
//
|
||||
@@ -271,11 +281,90 @@
|
||||
this.label1.Text = "Port";
|
||||
this.label1.Visible = false;
|
||||
//
|
||||
// STATUS_STRB_DW0
|
||||
//
|
||||
this.STATUS_STRB_DW0.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.STATUS_STRB_DW0.Location = new System.Drawing.Point(582, 97);
|
||||
this.STATUS_STRB_DW0.Margin = new System.Windows.Forms.Padding(4);
|
||||
this.STATUS_STRB_DW0.Name = "STATUS_STRB_DW0";
|
||||
this.STATUS_STRB_DW0.Size = new System.Drawing.Size(387, 28);
|
||||
this.STATUS_STRB_DW0.TabIndex = 69;
|
||||
//
|
||||
// lblPLC_ADP
|
||||
//
|
||||
this.lblPLC_ADP.AutoSize = true;
|
||||
this.lblPLC_ADP.Location = new System.Drawing.Point(517, 101);
|
||||
this.lblPLC_ADP.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.lblPLC_ADP.Name = "lblPLC_ADP";
|
||||
this.lblPLC_ADP.Size = new System.Drawing.Size(63, 17);
|
||||
this.lblPLC_ADP.TabIndex = 68;
|
||||
this.lblPLC_ADP.Text = "BIT-MAP";
|
||||
//
|
||||
// gbMonitor
|
||||
//
|
||||
this.gbMonitor.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.gbMonitor.BackColor = System.Drawing.Color.Black;
|
||||
this.gbMonitor.Controls.Add(this.lblOutMessage3);
|
||||
this.gbMonitor.Controls.Add(this.lblOutMessage2);
|
||||
this.gbMonitor.Controls.Add(this.lblOutMessage);
|
||||
this.gbMonitor.ForeColor = System.Drawing.SystemColors.Control;
|
||||
this.gbMonitor.Location = new System.Drawing.Point(3, 137);
|
||||
this.gbMonitor.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.gbMonitor.Name = "gbMonitor";
|
||||
this.gbMonitor.Padding = new System.Windows.Forms.Padding(0);
|
||||
this.gbMonitor.Size = new System.Drawing.Size(971, 265);
|
||||
this.gbMonitor.TabIndex = 70;
|
||||
this.gbMonitor.TabStop = false;
|
||||
this.gbMonitor.Text = "Monitor variabili";
|
||||
//
|
||||
// lblOutMessage3
|
||||
//
|
||||
this.lblOutMessage3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.lblOutMessage3.AutoSize = true;
|
||||
this.lblOutMessage3.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lblOutMessage3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(128)))), ((int)(((byte)(0)))));
|
||||
this.lblOutMessage3.Location = new System.Drawing.Point(459, 15);
|
||||
this.lblOutMessage3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.lblOutMessage3.Name = "lblOutMessage3";
|
||||
this.lblOutMessage3.Size = new System.Drawing.Size(16, 15);
|
||||
this.lblOutMessage3.TabIndex = 62;
|
||||
this.lblOutMessage3.Text = "...";
|
||||
//
|
||||
// lblOutMessage2
|
||||
//
|
||||
this.lblOutMessage2.Anchor = System.Windows.Forms.AnchorStyles.Top;
|
||||
this.lblOutMessage2.AutoSize = true;
|
||||
this.lblOutMessage2.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lblOutMessage2.ForeColor = System.Drawing.Color.Yellow;
|
||||
this.lblOutMessage2.Location = new System.Drawing.Point(245, 15);
|
||||
this.lblOutMessage2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.lblOutMessage2.Name = "lblOutMessage2";
|
||||
this.lblOutMessage2.Size = new System.Drawing.Size(16, 15);
|
||||
this.lblOutMessage2.TabIndex = 61;
|
||||
this.lblOutMessage2.Text = "...";
|
||||
//
|
||||
// lblOutMessage
|
||||
//
|
||||
this.lblOutMessage.AutoSize = true;
|
||||
this.lblOutMessage.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.lblOutMessage.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(255)))), ((int)(((byte)(128)))));
|
||||
this.lblOutMessage.Location = new System.Drawing.Point(4, 15);
|
||||
this.lblOutMessage.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.lblOutMessage.Name = "lblOutMessage";
|
||||
this.lblOutMessage.Size = new System.Drawing.Size(16, 15);
|
||||
this.lblOutMessage.TabIndex = 60;
|
||||
this.lblOutMessage.Text = "...";
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(706, 374);
|
||||
this.ClientSize = new System.Drawing.Size(974, 427);
|
||||
this.Controls.Add(this.gbMonitor);
|
||||
this.Controls.Add(this.STATUS_STRB_DW0);
|
||||
this.Controls.Add(this.lblPLC_ADP);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.tableLayoutPanel1);
|
||||
this.Controls.Add(this.statusStrip1);
|
||||
@@ -294,6 +383,8 @@
|
||||
this.tableLayoutPanel1.PerformLayout();
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
this.groupBox1.PerformLayout();
|
||||
this.gbMonitor.ResumeLayout(false);
|
||||
this.gbMonitor.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@@ -308,7 +399,7 @@
|
||||
private System.Windows.Forms.ContextMenuStrip trayMenu;
|
||||
private System.Windows.Forms.ToolStripStatusLabel lblApp;
|
||||
private System.Windows.Forms.ToolStripStatusLabel lblVers;
|
||||
private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar1;
|
||||
private System.Windows.Forms.ToolStripProgressBar MainProgrBar;
|
||||
private System.Windows.Forms.ToolStripStatusLabel lblComStats;
|
||||
private System.Windows.Forms.ToolStripStatusLabel lblStatus;
|
||||
private System.Windows.Forms.ToolStripMenuItem FileTSMI;
|
||||
@@ -323,5 +414,11 @@
|
||||
private System.Windows.Forms.Button start;
|
||||
private System.Windows.Forms.TextBox port;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.TextBox STATUS_STRB_DW0;
|
||||
private System.Windows.Forms.Label lblPLC_ADP;
|
||||
private System.Windows.Forms.GroupBox gbMonitor;
|
||||
private System.Windows.Forms.Label lblOutMessage3;
|
||||
private System.Windows.Forms.Label lblOutMessage2;
|
||||
private System.Windows.Forms.Label lblOutMessage;
|
||||
}
|
||||
}
|
||||
+196
-52
@@ -27,7 +27,6 @@ namespace IOB_WIN
|
||||
/// contatore veloce
|
||||
/// </summary>
|
||||
protected int fastCount;
|
||||
#if false
|
||||
/// <summary>
|
||||
/// contatore normale
|
||||
/// </summary>
|
||||
@@ -40,7 +39,6 @@ namespace IOB_WIN
|
||||
/// contatore sync allarmi
|
||||
/// </summary>
|
||||
protected int alarmSyncCount;
|
||||
#endif
|
||||
/// <summary>
|
||||
/// timer base in avvio
|
||||
/// </summary>
|
||||
@@ -75,21 +73,7 @@ namespace IOB_WIN
|
||||
#endregion
|
||||
|
||||
#region utils ed helpers
|
||||
|
||||
#if false
|
||||
public static void EnableTab(TabPage page, bool enable)
|
||||
{
|
||||
EnableControls(page.Controls, enable);
|
||||
}
|
||||
private static void EnableControls(Control.ControlCollection ctls, bool enable)
|
||||
{
|
||||
foreach (Control ctl in ctls)
|
||||
{
|
||||
ctl.Enabled = enable;
|
||||
EnableControls(ctl.Controls, enable);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private class Item
|
||||
{
|
||||
public string Name;
|
||||
@@ -122,6 +106,27 @@ namespace IOB_WIN
|
||||
|
||||
#region gestione form e visibilità
|
||||
|
||||
// apro eseguibile dump
|
||||
private void dump_Click(object sender, EventArgs e)
|
||||
{
|
||||
apriDumpAgent();
|
||||
}
|
||||
/// <summary>
|
||||
/// apre agent di dump in CMD
|
||||
/// </summary>
|
||||
private static void apriDumpAgent()
|
||||
{
|
||||
string path = Application.StartupPath;
|
||||
try
|
||||
{
|
||||
Process.Start(string.Format(@"{0}\..\..\dump\dump.exe", path));
|
||||
}
|
||||
catch
|
||||
{
|
||||
Process.Start(string.Format(@"{0}\dump\dump.exe", path));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Avvio MainForm
|
||||
/// </summary>
|
||||
@@ -165,23 +170,19 @@ namespace IOB_WIN
|
||||
// se abilitato autoload conf leggo file corretto...
|
||||
if (utils.CRB("autoLoadConf"))
|
||||
{
|
||||
#if false
|
||||
loadXmlFile(defConfFilePath);
|
||||
lg.Info("XML LOADED");
|
||||
loadPersistLayer(defPersLayerFile);
|
||||
loadIniFile(utils.defConfFilePath);
|
||||
lg.Info("INI LOADED");
|
||||
loadPersistLayer(utils.defPersLayerFile);
|
||||
lg.Info("PersLayerFile READ");
|
||||
agObj.loadPersData();
|
||||
#endif
|
||||
iobObj.loadPersData();
|
||||
lg.Info("PersLayerFile LOADED");
|
||||
}
|
||||
else
|
||||
{
|
||||
// definisco e avvio tipo adapter generico
|
||||
tipoScelto = tipoAdapter.ND;
|
||||
#if false
|
||||
adpConf = new AdapterConf();
|
||||
loadAdapterType();
|
||||
#endif
|
||||
IOBConf = new IobConfiguration();
|
||||
loadIobType();
|
||||
displayTaskAndWait("Waiting for config file selection");
|
||||
}
|
||||
|
||||
@@ -231,7 +232,7 @@ namespace IOB_WIN
|
||||
displayTaskAndWait("Main Form SHOWN");
|
||||
}
|
||||
/// <summary>
|
||||
/// COmpletato resize form
|
||||
/// Completato resize form
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
@@ -355,23 +356,19 @@ namespace IOB_WIN
|
||||
/// <param name="tryRestart">determina se tentare di riconnettersi</param>
|
||||
private void fermaTutto(bool stopTimer, bool tryRestart)
|
||||
{
|
||||
#if false
|
||||
agObj.stopAdapter(tryRestart);
|
||||
iobObj.stopAdapter(tryRestart);
|
||||
// salvo!
|
||||
savePersistLayer(defPersLayerFile);
|
||||
savePersistLayer(histPersLayerFile);
|
||||
savePersistLayer(utils.defPersLayerFile);
|
||||
savePersistLayer(utils.histPersLayerFile);
|
||||
|
||||
stop.Enabled = false;
|
||||
dump.Enabled = false;
|
||||
start.Enabled = true;
|
||||
#endif
|
||||
|
||||
if (stopTimer)
|
||||
{
|
||||
gather.Enabled = false;
|
||||
#if false
|
||||
agObj.tryDisconnect();
|
||||
#endif
|
||||
iobObj.tryDisconnect();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,19 +393,82 @@ namespace IOB_WIN
|
||||
serverUrl = fIni.ReadString("SERVER", "MPURL", "/")
|
||||
};
|
||||
|
||||
loadAdapterType();
|
||||
loadIobType();
|
||||
// avvio macchina con adapter specificato...
|
||||
if (utils.CRB("autoStartOnLoad"))
|
||||
{
|
||||
displayTaskAndWait("Auto Starting...");
|
||||
#if false
|
||||
// avvio!
|
||||
avviaAdapter();
|
||||
#endif
|
||||
avviaAdapter();
|
||||
displayTaskAndWait("Auto Started!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Salva su file l'oggetto di persistenza dati
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
public void savePersistLayer(string filePath)
|
||||
{
|
||||
// in primis check semaforo salvataggio...
|
||||
if (!iobObj.adpSaving)
|
||||
{
|
||||
// alzo semaforo salvataggio
|
||||
iobObj.adpSaving = true;
|
||||
// se HO dei dati...
|
||||
if (iobObj.persistenceLayer != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
utils.WritePlain(iobObj.persistenceLayer, filePath);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
lg.Error(string.Format("Errore salvataggio file{0}{1}", Environment.NewLine, exc));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lg.Info("persistenceLayer null, non salvato...");
|
||||
}
|
||||
// abbasso semaforo salvataggio
|
||||
iobObj.adpSaving = false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Carica da file l'oggetto di persistenza dati
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
public void loadPersistLayer(string filePath)
|
||||
{
|
||||
// inizializzo prima di leggere...
|
||||
iobObj.persistenceLayer = new Dictionary<string, string>();
|
||||
iobObj.persistenceLayer = utils.ReadPlain(filePath);
|
||||
|
||||
// 2017.03.23 check problema files corrotti...
|
||||
if (iobObj.persistenceLayer.Count == 0)
|
||||
{
|
||||
// se avesse letto un valore NON coerente (senza righe) PROVA a leggere a ritroso vecchi files... da histPersLayerFile e precedenti...
|
||||
int numDD = 0;
|
||||
int maxNumDD = utils.CRI("maxNumDD");
|
||||
Dictionary<string, string> lastRead = new Dictionary<string, string>();
|
||||
// continuo fino a che non leggo almeno 1 riga valida e non ho raggiunto maxDD
|
||||
while (numDD < maxNumDD && lastRead.Count == 0)
|
||||
{
|
||||
// leggo il file storico alla data anticipata... (ci provo...)
|
||||
try
|
||||
{
|
||||
lastRead = utils.ReadPlain(utils.prevPersLayerFile(numDD));
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
numDD++;
|
||||
}
|
||||
// se sono uscito PROVO a passare il file storico letto buono (oppure vuoto...)
|
||||
iobObj.persistenceLayer = lastRead;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void mLoadConf_Click(object sender, EventArgs e)
|
||||
@@ -433,19 +493,17 @@ namespace IOB_WIN
|
||||
string iniConfFile = openFileDial.FileName;
|
||||
loadIniFile(iniConfFile);
|
||||
lg.Info("INI LOADED");
|
||||
#if false
|
||||
loadPersistLayer(defPersLayerFile);
|
||||
loadPersistLayer(utils.defPersLayerFile);
|
||||
lg.Info("PersLayerFile READ");
|
||||
agObj.loadPersData();
|
||||
iobObj.loadPersData();
|
||||
lg.Info("PersLayerFile LOADED");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// carica adapter richiesto
|
||||
/// carica IOB richiesto
|
||||
/// </summary>
|
||||
private void loadAdapterType()
|
||||
private void loadIobType()
|
||||
{
|
||||
switch (tipoScelto)
|
||||
{
|
||||
@@ -457,10 +515,10 @@ namespace IOB_WIN
|
||||
iobObj = new IobFanuc(this, IOBConf);
|
||||
start.Enabled = true;
|
||||
break;
|
||||
//case tipoAdapter.SIEMENS:
|
||||
// agObj = new AdapterSiemens(this, adpConf);
|
||||
// start.Enabled = true;
|
||||
// break;
|
||||
case tipoAdapter.SIEMENS:
|
||||
iobObj = new IobSiemens(this, IOBConf);
|
||||
start.Enabled = true;
|
||||
break;
|
||||
case tipoAdapter.ND:
|
||||
default:
|
||||
iobObj = new IobDemo(this, IOBConf);
|
||||
@@ -471,10 +529,96 @@ namespace IOB_WIN
|
||||
lblTopCent.Text = string.Format("IOB {0}", IOBConf.codIOB);
|
||||
lblTopDx.Text = string.Format("SRV: {0}{1}URL: {2}", IOBConf.serverIpAddr, Environment.NewLine, IOBConf.serverUrl);
|
||||
|
||||
//// carico i default values su interfaccia
|
||||
//setDefaults();
|
||||
// carico i default values su interfaccia
|
||||
setDefaults();
|
||||
|
||||
displayTaskAndWait(string.Format("Caricata conf per adapter {0}", tipoScelto));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// impostazione valori defaults
|
||||
/// </summary>
|
||||
private void setDefaults()
|
||||
{
|
||||
stop.Enabled = false;
|
||||
dump.Enabled = false;
|
||||
|
||||
STATUS_STRB_DW0.Text = utils.binaryForm(0);
|
||||
|
||||
MainProgrBar.Minimum = 0;
|
||||
MainProgrBar.Maximum = 1000;
|
||||
MainProgrBar.Value = 0;
|
||||
MainProgrBar.Step = 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Avvio dell'adapter
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void start_Click(object sender, EventArgs e)
|
||||
{
|
||||
avviaAdapter();
|
||||
iobObj.loadPersData();
|
||||
// salvo che ho avviato adapter
|
||||
lg.Info("Completato LOAD Adapter");
|
||||
}
|
||||
|
||||
public void avviaAdapter()
|
||||
{
|
||||
displayTaskAndWait("Adapter starting");
|
||||
// se NON sta girando...
|
||||
if (!iobObj.adpRunning)
|
||||
{
|
||||
int porta = Convert.ToInt32(port.Text);
|
||||
iobObj.startAdapter(porta);
|
||||
displayTaskAndWait("Adapter started!");
|
||||
|
||||
// fix buttons start/stop/dump
|
||||
start.Enabled = false;
|
||||
stop.Enabled = true;
|
||||
dump.Enabled = true;
|
||||
if (utils.CRB("openDumpOnStart"))
|
||||
{
|
||||
displayTaskAndWait("Dump Window starting");
|
||||
apriDumpAgent();
|
||||
displayTaskAndWait("Dump Windows OK");
|
||||
}
|
||||
|
||||
displayTaskAndWait("Start Timers");
|
||||
// inizializzo contatori fast/mid/slow
|
||||
fastCount = utils.CRI("fastCount");
|
||||
normCount = utils.CRI("normCount");
|
||||
slowCount = utils.CRI("slowCount");
|
||||
alarmSyncCount = utils.CRI("alarmSyncCount");
|
||||
displayTaskAndWait("Adapter Running...");
|
||||
// forzo check allarmi..
|
||||
iobObj.forceAlarmCheck();
|
||||
}
|
||||
else
|
||||
{
|
||||
displayTaskAndWait("Adapter STILL Running...");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// fermata dell'adapter
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void stop_Click(object sender, EventArgs e)
|
||||
{
|
||||
fermaAdapter(false);
|
||||
// salvo che ho fermato adapter
|
||||
lg.Info("UNLOAD Adapter");
|
||||
}
|
||||
/// <summary>
|
||||
/// Ferma l'adapter
|
||||
/// </summary>
|
||||
/// <param name="tryRestart">determina se si debba tentare riavvio automatico (per caduta connessione)</param>
|
||||
public void fermaAdapter(bool tryRestart)
|
||||
{
|
||||
fermaTutto(false, tryRestart);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
cl dump.c ws2_32.lib
|
||||
@@ -0,0 +1,184 @@
|
||||
#include <stdio.h>
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
#include <sys/select.h>
|
||||
#include <stdlib.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
|
||||
#define PORT 7878
|
||||
#define HOST "localhost"
|
||||
#define BUFFER_SIZE 1024
|
||||
|
||||
#ifndef _WIN32
|
||||
#define SOCKET int
|
||||
#define closesocket close
|
||||
#endif
|
||||
|
||||
void cleanup_and_exit(int ret)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
WSACleanup();
|
||||
#endif
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
void usage()
|
||||
{
|
||||
fprintf(stderr, "Usage: dump [-t timeout] [host] [port] [file]\n host defaults to localhost\n port defaults to 7878\n file defaults to stdout\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char hostname[100];
|
||||
SOCKET sd;
|
||||
struct sockaddr_in pin;
|
||||
struct hostent *hp;
|
||||
char buffer[BUFFER_SIZE];
|
||||
int port;
|
||||
FILE *file;
|
||||
char dump = 0;
|
||||
char **argvp = argv;
|
||||
time_t start = 0;
|
||||
int remaining = 1, timeout = 0, nfds;
|
||||
struct fd_set fds;
|
||||
struct timeval tv, *tvp = 0;
|
||||
|
||||
#ifdef _WIN32
|
||||
WSADATA wsaData;
|
||||
if (WSAStartup(MAKEWORD(2,0), &wsaData) != 0) {
|
||||
fprintf(stderr, "WSAStartup failed\n");
|
||||
cleanup_and_exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
if (strcmp(argv[1], "-h") == 0) {
|
||||
usage();
|
||||
} else if (strcmp(argv[1], "-t") == 0) {
|
||||
if (argc < 3) {
|
||||
fprintf(stderr, "Missing timeout argument\n");
|
||||
usage();
|
||||
}
|
||||
timeout = atoi(argv[2]);
|
||||
argc -= 2;
|
||||
argvp += 2;
|
||||
}
|
||||
}
|
||||
|
||||
strcpy(hostname,HOST);
|
||||
if (argc > 1) {
|
||||
strcpy(hostname,argvp[1]);
|
||||
}
|
||||
|
||||
port = PORT;
|
||||
if (argc > 2) {
|
||||
port = atoi(argvp[2]);
|
||||
}
|
||||
|
||||
file = stdout;
|
||||
if (argc > 3) {
|
||||
file = fopen(argvp[3], "w");
|
||||
if (file == NULL) {
|
||||
perror("fopen");
|
||||
fprintf(stderr, "Cannot open file %s\n", argv[3]);
|
||||
exit(1);
|
||||
}
|
||||
dump = 1;
|
||||
}
|
||||
|
||||
/* go find out about the desired host machine */
|
||||
if ((hp = gethostbyname(hostname)) == (void*) 0) {
|
||||
perror("gethostbyname");
|
||||
cleanup_and_exit(1);
|
||||
}
|
||||
|
||||
/* fill in the socket structure with host information */
|
||||
memset(&pin, 0, sizeof(pin));
|
||||
pin.sin_family = AF_INET;
|
||||
memcpy(&pin.sin_addr.s_addr, hp->h_addr, hp->h_length);
|
||||
pin.sin_port = htons(port);
|
||||
|
||||
/* grab an Internet domain socket */
|
||||
if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
|
||||
perror("socket");
|
||||
cleanup_and_exit(1);
|
||||
}
|
||||
|
||||
/* connect to PORT on HOST */
|
||||
if (connect(sd,(struct sockaddr *) &pin, sizeof(pin)) == -1) {
|
||||
perror("connect");
|
||||
cleanup_and_exit(1);
|
||||
}
|
||||
|
||||
if (dump) {
|
||||
printf("Connected to %s port %d\n", hostname, port);
|
||||
}
|
||||
|
||||
/* wait for a message to come back from the server */
|
||||
if (timeout > 0) {
|
||||
start = time(0);
|
||||
remaining = timeout;
|
||||
tv.tv_usec = 0;
|
||||
tvp = &tv;
|
||||
}
|
||||
#ifdef _WIN32
|
||||
nfds = 1;
|
||||
#else
|
||||
nfds = sd + 1;
|
||||
#endif
|
||||
while (remaining > 0) {
|
||||
int n;
|
||||
|
||||
FD_ZERO(&fds);
|
||||
FD_SET(sd, &fds);
|
||||
tv.tv_sec = remaining;
|
||||
n = select(nfds, &fds, (fd_set*) 0, (fd_set*) 0, tvp);
|
||||
if (n < 0) {
|
||||
closesocket(sd);
|
||||
perror("recv");
|
||||
cleanup_and_exit(1);
|
||||
} else if (n > 0) {
|
||||
int count = recv(sd, buffer, BUFFER_SIZE, 0);
|
||||
if (count == -1) {
|
||||
closesocket(sd);
|
||||
perror("recv");
|
||||
cleanup_and_exit(1);
|
||||
}
|
||||
if (count == 0)
|
||||
break;
|
||||
fwrite(buffer, 1, count, file);
|
||||
if (dump) {
|
||||
fputc('.', stdout);
|
||||
fflush(stdout);
|
||||
}
|
||||
fflush(file);
|
||||
}
|
||||
|
||||
if (timeout > 0) {
|
||||
time_t now = time(0);
|
||||
remaining -= (int) (now - start);
|
||||
start = now;
|
||||
}
|
||||
}
|
||||
|
||||
if (dump) printf("\nFinished\n");
|
||||
|
||||
fclose(file);
|
||||
closesocket(sd);
|
||||
#ifdef _WIN32
|
||||
WSACleanup();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
Binary file not shown.
@@ -1,4 +1,5 @@
|
||||
using System.Windows.Forms;
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace IOB_WIN
|
||||
{
|
||||
@@ -64,6 +65,26 @@ namespace IOB_WIN
|
||||
return string.Format(@"{0}\{1}", utils.dataDatDir, utils.CRS("defaultPersLayerFile"));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// file persistenza generale
|
||||
/// </summary>
|
||||
public static string histPersLayerFile
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(@"{0}\{1:yyyy}\{1:yyyy-MM-dd}.mtc", utils.dataDatDir, DateTime.Now);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// file persistenza generale data attuale ANTICIPATA di xx giorni
|
||||
/// </summary>
|
||||
/// <param name="numDD">num DD di anticipo</param>
|
||||
/// <returns></returns>
|
||||
public static string prevPersLayerFile(int numDD)
|
||||
{
|
||||
return string.Format(@"{0}\{1:yyyy}\{1:yyyy-MM-dd}.mtc", utils.dataDatDir, DateTime.Now.AddDays(-numDD));
|
||||
}
|
||||
/// <summary>
|
||||
/// File icona default
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user