modifica XML sia x ADAPTER che x AGENT
Fix adapter generic x lettura parametri da XML
Fix Fanuc/Esa x compilazioen nuova versione
Fix gestioen icon
This commit is contained in:
Samuele E. Locatelli
2016-07-06 15:05:49 +02:00
parent 21b159aa02
commit 369e08ac93
13 changed files with 192 additions and 77 deletions
+2
View File
@@ -226,11 +226,13 @@
<Actuator id="VacPump_01" name ="Pompa 1">
<DataItems>
<DataItem category="EVENT" id="VacPump_01_Status" name="Stato Pompa 1" type="ACTUATOR_STATE"/>
<DataItem category="SAMPLE" id="VacPump_01_WrkTime" name="Tempo macchina in RUN" type="ACCUMULATED_TIME"/>
</DataItems>
</Actuator>
<Actuator id="VacPump_02" name ="Pompa 2">
<DataItems>
<DataItem category="EVENT" id="VacPump_02_Status" name="Stato Pompa 2" type="ACTUATOR_STATE"/>
<DataItem category="SAMPLE" id="VacPump_02_WrkTime" name="Tempo macchina in RUN" type="ACCUMULATED_TIME"/>
</DataItems>
</Actuator>
<Actuator id="VacAct_01" name ="Valvola vuoto 1">
+2
View File
@@ -226,11 +226,13 @@
<Actuator id="VacPump_01" name ="Pompa 1">
<DataItems>
<DataItem category="EVENT" id="VacPump_01_Status" name="Stato Pompa 1" type="ACTUATOR_STATE"/>
<DataItem category="SAMPLE" id="VacPump_01_WrkTime" name="Tempo macchina in RUN" type="ACCUMULATED_TIME"/>
</DataItems>
</Actuator>
<Actuator id="VacPump_02" name ="Pompa 2">
<DataItems>
<DataItem category="EVENT" id="VacPump_02_Status" name="Stato Pompa 2" type="ACTUATOR_STATE"/>
<DataItem category="SAMPLE" id="VacPump_02_WrkTime" name="Tempo macchina in RUN" type="ACCUMULATED_TIME"/>
</DataItems>
</Actuator>
<Actuator id="VacAct_01" name ="Valvola vuoto 1">
@@ -15,6 +15,10 @@
<Key>VacPump_01_Status</Key>
<Value>0</Value>
</dataRef>
<dataRef>
<Key>VacPump_01_WrkTime</Key>
<Value>0</Value>
</dataRef>
</dataRefList>
</element>
<element>
@@ -26,6 +30,10 @@
<Key>VacPump_02_Status</Key>
<Value>0</Value>
</dataRef>
<dataRef>
<Key>VacPump_02_WrkTime</Key>
<Value>0</Value>
</dataRef>
</dataRefList>
</element>
</VacuumPump>
+8
View File
@@ -15,6 +15,10 @@
<Key>VacPump_01_Status</Key>
<Value>0</Value>
</dataRef>
<dataRef>
<Key>VacPump_01_WrkTime</Key>
<Value>0</Value>
</dataRef>
</dataRefList>
</element>
<element>
@@ -26,6 +30,10 @@
<Key>VacPump_02_Status</Key>
<Value>0</Value>
</dataRef>
<dataRef>
<Key>VacPump_02_WrkTime</Key>
<Value>0</Value>
</dataRef>
</dataRefList>
</element>
</VacuumPump>
+2 -2
View File
@@ -841,11 +841,11 @@ namespace MTC_Adapter
}
else if (maintData[i].varName.StartsWith("Lubro_"))
{
if (maintData[i].varName.EndsWith("_Count"))
if (maintData[i].varName.EndsWith("_Num"))
{
try
{
numero = Convert.ToInt32(maintData[i].varName.Replace("Lubro_", "").Replace("_Count", ""));
numero = Convert.ToInt32(maintData[i].varName.Replace("Lubro_", "").Replace("_Num", ""));
}
catch
{ }
+67 -51
View File
@@ -1230,10 +1230,12 @@ namespace MTC_Adapter
}
currPathPartId = new string[currAdpConf.nPath];
istPathPartId = new string[currAdpConf.nPath];
currPathPartCount = new uint[currAdpConf.nPath];
istPathPartCount = new uint[currAdpConf.nPath];
for (int i = 0; i < currAdpConf.nPath; i++)
{
// leggo tutti i dati...
List<DataRefItem<string, string>> listaDR = currAdpConf.Axis[i].dataRefList;
List<DataRefItem<string, string>> listaDR = currAdpConf.Path[i].dataRefList;
// punto all'item
DataRefItem<string, string> riPathProgr = listaDR.Find(x => x.Key == string.Format("Path_{0:00}_PartId", i + 1));
DataRefItem<string, string> riPathPzTot = listaDR.Find(x => x.Key == string.Format("Path_{0:00}_PZ_TOT", i + 1));
@@ -1279,7 +1281,7 @@ namespace MTC_Adapter
mAlarmCNC.Normal();
mAlarmPLC.Normal();
mAlarmGeneral.Normal();
lg.Info("Adapter Started!");
parentForm.displayTaskAndWait("Adapter Started!");
}
/// <summary>
/// Effettua refresh del vettore privato degli allarmi attivi
@@ -1297,13 +1299,13 @@ namespace MTC_Adapter
public void stopAdapter()
{
mStatus.Value = "OFF";
lg.Info("Stopping adapter...");
parentForm.displayTaskAndWait("Stopping adapter...");
// chiudo la connessione all'adapter...
tryDisconnect();
// Stop everything...
mAdapter.Stop();
dtStopAdp = DateTime.Now;
lg.Info("Adapter Stopped!");
parentForm.displayTaskAndWait("Adapter Stopped!");
}
/// <summary>
@@ -1318,62 +1320,76 @@ namespace MTC_Adapter
// controllo non sia già in esecuzione...
if (!adpRunning)
{
// imposto flag adapter running..
adpRunning = true;
// avvio fase raccolta dati
mAdapter.Begin();
// processing degli strobes di allarme (da ULTIMA rappresentazione vettore dell'ADP)
processAlarm();
// processo e svuoto eventuali code di invio per Codici M/S/T
trySendCodMST();
// ciclo HF: recupero update status & strobes vari
if (ciclo == gatherCycle.HF)
// provo ad avviare
try
{
// parte che eseguo SEMPRE: RECUPERO stato di tutti gli strobe/status e degli ack attualmente noti
getStrobeAndAckStatus();
// faccio refresh degli allarmi segnalati (da strobe su vettore locale)
refreshAlarmState(STRB_DW0, true);
// acquisizione degli status
processStatus();
// processing degli strobes
processStrobe();
// avvio fase raccolta dati
mAdapter.Begin();
// imposto flag adapter running..
adpRunning = true;
}
else if (ciclo == gatherCycle.MF)
catch (Exception exc)
{
// leggo parametri a media freq (dati globali, path, assi, Unità Operatrice)
getGlobalData();
getUnOp();
getPath();
getAxis();
parentForm.displayTaskAndWait(string.Format("Adapter NO STARTED!!!{0}{1}", Environment.NewLine, exc));
adpRunning = false;
}
// ciclo lento
else if (ciclo == gatherCycle.LF)
if (adpRunning)
{
// leggo EVENTUALI parametri da config file
getConfigParam();
///acquisisco dati su programma in esecuzione e dati generali (stato, orologio, power...)
getSlowChangingData();
// processing degli strobes di allarme (da ULTIMA rappresentazione vettore dell'ADP)
processAlarm();
// processo e svuoto eventuali code di invio per Codici M/S/T
trySendCodMST();
// eventuale log!
if (utils.CRB("recTime")) logTimeResults();
// ciclo HF: recupero update status & strobes vari
if (ciclo == gatherCycle.HF)
{
// parte che eseguo SEMPRE: RECUPERO stato di tutti gli strobe/status e degli ack attualmente noti
getStrobeAndAckStatus();
// faccio refresh degli allarmi segnalati (da strobe su vettore locale)
refreshAlarmState(STRB_DW0, true);
// acquisizione degli status
processStatus();
// processing degli strobes
processStrobe();
}
else if (ciclo == gatherCycle.MF)
{
// leggo parametri a media freq (dati globali, path, assi, Unità Operatrice)
getGlobalData();
getUnOp();
getPath();
getAxis();
}
// ciclo lento
else if (ciclo == gatherCycle.LF)
{
// leggo EVENTUALI parametri da config file
getConfigParam();
///acquisisco dati su programma in esecuzione e dati generali (stato, orologio, power...)
getSlowChangingData();
// eventuale log!
if (utils.CRB("recTime")) logTimeResults();
}
// ciclo lentissimo
else if (ciclo == gatherCycle.VLF)
{
lg.Info("Richiesta lettura completa allarmi attivi");
// faccio comunque rilettura completa allarmi...
forceAlarmCheck();
}
// INVIO dati variati!
mAdapter.SendChanged();
// tolgo flag running
adpRunning = false;
}
// ciclo lentissimo
else if (ciclo == gatherCycle.VLF)
else
{
lg.Info("Richiesta lettura completa allarmi attivi");
// faccio comunque rilettura completa allarmi...
forceAlarmCheck();
lg.Info("ADP not running...");
}
// INVIO dati variati!
mAdapter.SendChanged();
// tolgo flag running
adpRunning = false;
}
else
{
+2
View File
@@ -4,7 +4,9 @@
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<appSettings>
<add key="appName" value="MTConnect Adapter" />
<!--gestione TIMERS e periodi multipli x thread lenti-->
<add key ="startTimerMs" value="250" />
<add key="timerIntMs" value="5" /> <!--invio da adapter ad agent: 10ms-->
<add key="fastCount" value="20" /> <!--100ms-->
<add key="normCount" value="50" /> <!--250ms-->
+3 -1
View File
@@ -152,7 +152,9 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Resources\SCM\SCM.ico" />
<Content Include="MTCA.ico" />
<Content Include="MTCA.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Resources\SCM\XSimGph.dll" />
<Content Include="SubMode.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
+33 -11
View File
@@ -115,7 +115,7 @@
this.STATUS_STRB_DW0 = new System.Windows.Forms.TextBox();
this.lblPLC_ADP = new System.Windows.Forms.Label();
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
this.lblStatus = new System.Windows.Forms.ToolStripStatusLabel();
this.MainProgrBar = new System.Windows.Forms.ToolStripProgressBar();
this.groupBox13 = new System.Windows.Forms.GroupBox();
this.cbPathSel = new System.Windows.Forms.ComboBox();
@@ -212,6 +212,8 @@
this.lblCodaM = new System.Windows.Forms.Label();
this.addCodM = new System.Windows.Forms.TextBox();
this.label20 = new System.Windows.Forms.Label();
this.lblApp = new System.Windows.Forms.ToolStripStatusLabel();
this.lblVers = new System.Windows.Forms.ToolStripStatusLabel();
this.groupBox4.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.PosAct)).BeginInit();
this.groupBox3.SuspendLayout();
@@ -1046,19 +1048,21 @@
//
this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabel1,
this.MainProgrBar});
this.lblApp,
this.lblStatus,
this.MainProgrBar,
this.lblVers});
this.statusStrip1.Location = new System.Drawing.Point(0, 716);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(785, 25);
this.statusStrip1.TabIndex = 59;
this.statusStrip1.Text = "statusStrip1";
//
// toolStripStatusLabel1
// lblStatus
//
this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
this.toolStripStatusLabel1.Size = new System.Drawing.Size(52, 20);
this.toolStripStatusLabel1.Text = "Running";
this.lblStatus.Name = "lblStatus";
this.lblStatus.Size = new System.Drawing.Size(22, 20);
this.lblStatus.Text = "---";
//
// MainProgrBar
//
@@ -1449,7 +1453,7 @@
this.tbConf.Location = new System.Drawing.Point(4, 22);
this.tbConf.Name = "tbConf";
this.tbConf.Padding = new System.Windows.Forms.Padding(3);
this.tbConf.Size = new System.Drawing.Size(777, 636);
this.tbConf.Size = new System.Drawing.Size(777, 640);
this.tbConf.TabIndex = 1;
this.tbConf.Text = "XML CONFIG";
//
@@ -1459,7 +1463,7 @@
this.wbXmlConf.Location = new System.Drawing.Point(3, 3);
this.wbXmlConf.MinimumSize = new System.Drawing.Size(20, 20);
this.wbXmlConf.Name = "wbXmlConf";
this.wbXmlConf.Size = new System.Drawing.Size(771, 630);
this.wbXmlConf.Size = new System.Drawing.Size(771, 634);
this.wbXmlConf.TabIndex = 0;
//
// tpSIM
@@ -1479,7 +1483,7 @@
this.tpSIM.Controls.Add(this.groupBox12);
this.tpSIM.Location = new System.Drawing.Point(4, 22);
this.tpSIM.Name = "tpSIM";
this.tpSIM.Size = new System.Drawing.Size(777, 636);
this.tpSIM.Size = new System.Drawing.Size(777, 640);
this.tpSIM.TabIndex = 2;
this.tpSIM.Text = "SIMULATION";
//
@@ -2017,6 +2021,22 @@
this.label20.TabIndex = 52;
this.label20.Text = "AddM";
//
// lblApp
//
this.lblApp.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold);
this.lblApp.ForeColor = System.Drawing.SystemColors.ControlText;
this.lblApp.Name = "lblApp";
this.lblApp.Size = new System.Drawing.Size(16, 20);
this.lblApp.Text = "...";
//
// lblVers
//
this.lblVers.Font = new System.Drawing.Font("Segoe UI", 8F);
this.lblVers.ForeColor = System.Drawing.SystemColors.ControlDarkDark;
this.lblVers.Name = "lblVers";
this.lblVers.Size = new System.Drawing.Size(16, 20);
this.lblVers.Text = "...";
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -2126,7 +2146,7 @@
private System.Windows.Forms.TextBox OPERATOR_ID;
private System.Windows.Forms.Label label19;
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
private System.Windows.Forms.ToolStripStatusLabel lblStatus;
private System.Windows.Forms.ToolStripProgressBar MainProgrBar;
private System.Windows.Forms.TextBox txtPzKo;
private System.Windows.Forms.Label label25;
@@ -2261,6 +2281,8 @@
private System.Windows.Forms.CheckBox ErrRT_03;
private System.Windows.Forms.Label lblOutMessage;
private System.Windows.Forms.Label label53;
private System.Windows.Forms.ToolStripStatusLabel lblApp;
private System.Windows.Forms.ToolStripStatusLabel lblVers;
}
}
+50 -8
View File
@@ -31,6 +31,8 @@ namespace MTC_Adapter
protected int slowCount;
protected int alarmSyncCount;
protected int startTimerMs;
public static Logger lg;
@@ -70,21 +72,41 @@ namespace MTC_Adapter
Name = name; Value = value;
}
}
/// <summary>
/// mostra un testo sulal status bar ed attende startTimerMs
/// </summary>
/// <param name="txt2show"></param>
public void displayTaskAndWait(string txt2show)
{
lblStatus.Text = txt2show;
lg.Info(txt2show);
Thread.Sleep(startTimerMs);
}
#endregion
public MainForm()
{
InitializeComponent();
lblStatus.Text = "Loading";
// fix icon!
this.Icon = Icon.ExtractAssociatedIcon(defIconFilePath);
// fix versione!
lblApp.Text = string.Format("{0}", ConfigurationManager.AppSettings.Get("appName"));
lblVers.Text = string.Format(" v.{0}", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version);
startTimerMs = utils.CRI("startTimerMs");
lg = LogManager.GetCurrentClassLogger();
lg.Info("Avvio MainForm");
displayTaskAndWait("Starting MainForm");
// inizio con tab control disabilitati
EnableTab(tabCtrlMain.TabPages[1], false);
EnableTab(tabCtrlMain.TabPages[2], false);
// seabilitato autoload conf leggo file corretto...
// se abilitato autoload conf leggo file corretto...
if (utils.CRB("autoLoadConf"))
{
loadXmlFile(defConfFilePath);
@@ -95,7 +117,10 @@ namespace MTC_Adapter
tipoScelto = tipoAdapter.ND;
adpConf = new AdapterConf();
loadAdapterType();
displayTaskAndWait("Waiting for config file selection");
}
displayTaskAndWait("Running");
}
protected string defConfFilePath
{
@@ -104,6 +129,13 @@ namespace MTC_Adapter
return string.Format(@"{0}\{1}\{2}", Application.StartupPath, utils.CRS("adapterConfPath"), utils.CRS("defaultConfFile"));
}
}
protected string defIconFilePath
{
get
{
return string.Format(@"{0}\MTCA.ico", Application.StartupPath);
}
}
/// <summary>
/// carica adapter richiesto
@@ -143,7 +175,7 @@ namespace MTC_Adapter
// carico i default values su interfaccia
setDefaults();
lg.Info("Caricata conf per adapter {0}", tipoScelto);
displayTaskAndWait(string.Format("Caricata conf per adapter {0}", tipoScelto));
}
/// <summary>
@@ -239,8 +271,11 @@ namespace MTC_Adapter
private void avviaAdapter()
{
displayTaskAndWait("Adapter starting");
int porta = Convert.ToInt32(port.Text);
agObj.startAdapter(porta);
displayTaskAndWait("Adapter started!");
// fix buttons start/stop/dump
start.Enabled = false;
@@ -248,9 +283,13 @@ namespace MTC_Adapter
dump.Enabled = true;
if (utils.CRB("openDumpOnStart"))
{
displayTaskAndWait("Dump Window starting");
apriDumpAgent();
displayTaskAndWait("Dump Windows OK");
}
displayTaskAndWait("Start Timers");
// Start timer periodico
gather.Interval = utils.CRI("timerIntMs");
gather.Enabled = true;
@@ -259,6 +298,8 @@ namespace MTC_Adapter
normCount = utils.CRI("normCount");
slowCount = utils.CRI("slowCount");
alarmSyncCount = utils.CRI("alarmSyncCount");
displayTaskAndWait("Timers Ready");
}
/// <summary>
@@ -309,7 +350,6 @@ namespace MTC_Adapter
if (alarmSyncCount <= 0)
{
alarmSyncCount = utils.CRI("alarmSyncCount");
//lg.Info("Reset alarmSyncCount");
// avvio fase raccolta dati e invio con adapter
agObj.gaterAndSend(gatherCycle.VLF);
@@ -322,7 +362,6 @@ namespace MTC_Adapter
if (slowCount <= 0)
{
slowCount = utils.CRI("slowCount");
//lg.Info("Reset slowCount");
// avvio fase raccolta dati e invio con adapter
agObj.gaterAndSend(gatherCycle.LF);
@@ -362,7 +401,6 @@ namespace MTC_Adapter
if (normCount <= 0)
{
normCount = utils.CRI("normCount");
//lg.Info("Reset normCount");
// avvio fase raccolta dati e invio con adapter
agObj.gaterAndSend(gatherCycle.MF);
@@ -378,7 +416,6 @@ namespace MTC_Adapter
if (fastCount <= 0)
{
fastCount = utils.CRI("fastCount");
//lg.Info("Reset fastCount");
// avvio fase raccolta dati e invio con adapter
agObj.gaterAndSend(gatherCycle.HF);
@@ -853,6 +890,8 @@ namespace MTC_Adapter
/// <param name="XmlConfFile"></param>
private void loadXmlFile(string XmlConfFile)
{
displayTaskAndWait("Loading XML");
// Read the configuration object from a file
adpConf = AdapterConf.Deserialize(XmlConfFile);
@@ -861,12 +900,15 @@ namespace MTC_Adapter
loadAdapterType();
// carico file XML in web browser...
wbXmlConf.DocumentText = AdapterConf.rawXml(XmlConfFile);
displayTaskAndWait("XML loaded");
// avvio macchina con adapter specificato...
if (utils.CRB("autoStartOnLoad"))
{
displayTaskAndWait("Auto Starting...");
// avvio!
avviaAdapter();
displayTaskAndWait("Auto Started!");
}
}
/// <summary>
+11
View File
@@ -15,6 +15,16 @@ namespace MTC_Adapter
public SetupAdapter()
{
InitializeComponent();
// fix icon!
this.Icon = Icon.ExtractAssociatedIcon(defIconFilePath);
}
protected string defIconFilePath
{
get
{
return string.Format(@"{0}\MTCA.ico", Application.StartupPath);
}
}
/// <summary>
/// Percorso file completo
@@ -235,6 +245,7 @@ namespace MTC_Adapter
// inizializzo list x parametri
listaDR = new List<DataRefItem<string, string>>();
listaDR.Add(new DataRefItem<string, string>(string.Format("VacPump_{0:00}_Status", i + 1), "0"));
listaDR.Add(new DataRefItem<string, string>(string.Format("VacPump_{0:00}_WrkTime", i + 1), "0"));
VacuumPump[i] = new element(string.Format("VacPump_{0:00}", i + 1), string.Format("Pompa {0}", i + 1), fonteDati.Random, listaDR);
}
// salvo oggetto
+2 -2
View File
@@ -5,7 +5,7 @@
using System.Reflection;
[assembly: AssemblyVersion("1.0.6.91")]
[assembly: AssemblyFileVersion("1.0.6.91")]
[assembly: AssemblyVersion("1.0.7.92")]
[assembly: AssemblyFileVersion("1.0.7.92")]
[assembly: AssemblyCopyright("Steamware-SCM-CMS © 2015-2016")]
[assembly: AssemblyCompany("Steamware-SCM-CMS")]
+2 -2
View File
@@ -6,8 +6,8 @@
using System.Reflection;
[assembly: AssemblyVersion("1.0.6.<#= this.RevisionNumber #>")]
[assembly: AssemblyFileVersion("1.0.6.<#= this.RevisionNumber #>")]
[assembly: AssemblyVersion("1.0.7.<#= this.RevisionNumber #>")]
[assembly: AssemblyFileVersion("1.0.7.<#= this.RevisionNumber #>")]
[assembly: AssemblyCopyright("Steamware-SCM-CMS © 2015-<#= DateTime.Now.Year #>")]
[assembly: AssemblyCompany("Steamware-SCM-CMS")]
<#+