Aggiunto Path a conf adapter XML

This commit is contained in:
Samuele E. Locatelli
2016-04-22 10:27:40 +02:00
parent fcd5f6d725
commit 467a0601a6
5 changed files with 222 additions and 169 deletions
Binary file not shown.
+9 -5
View File
@@ -29,10 +29,11 @@ namespace MTC_Sim
element[] _Cooler;
element[] _Press;
element[] _Temp;
int nAxis;
element[] _Path;
int nPath;
int nUnOp;
int nAxis;
/// <summary>
/// init conf adapter
@@ -42,10 +43,8 @@ namespace MTC_Sim
sNomeAdapt = "";
etipoAdapt = tipoAdapter.Demo;
nAxis = 0;
nPath = 0;
nUnOp = 0;
nAxis = 0;
}
/// <summary>
/// Serializzazione XML dell'oggetto conf dell'adapter
@@ -118,6 +117,11 @@ namespace MTC_Sim
get { return _Temp; }
set { _Temp = value; }
}
public element[] Path
{
get { return _Path; }
set { _Path = value; }
}
}
+145 -158
View File
@@ -208,6 +208,151 @@ namespace MTC_Sim
mTempValIst = new Sample(string.Format("{0}_ValIst", Idx));
}
}
/// <summary>
/// Singolo path, da 1..20
/// </summary>
public class Path : element
{
/// <summary>
/// Alias
/// </summary>
public Event mPathAlias;
/// <summary>
/// Feedrate
/// </summary>
public Sample mPathFeed;
/// <summary>
/// Override feed
/// </summary>
public Sample mPathFeedOver;
/// <summary>
/// Override speed
/// </summary>
public Sample mPathSpeedOver;
/// <summary>
/// Posizione X
/// </summary>
public Sample mPathPosActX;
/// <summary>
/// Posizione Y
/// </summary>
public Sample mPathPosActY;
/// <summary>
/// Posizione Z
/// </summary>
public Sample mPathPosActZ;
/// <summary>
/// Angolo I
/// </summary>
public Sample mPathPosActI;
/// <summary>
/// Angolo J
/// </summary>
public Sample mPathPosActJ;
/// <summary>
/// Angolo K
/// </summary>
public Sample mPathPosActK;
/// <summary>
/// Classe Path con Idx e descrizione
/// </summary>
/// <param name="Idx">Identificativo univoco</param>
/// <param name="Alias">Alias/descrizione</param>
/// <param name="FonteD">Tipo fonte dati</param>
/// <param name="DataRefList">Parametri x recupero dati in forma dictionary</param>
public Path(string Idx, string Alias, fonteDati FonteD, List<DataRefItem<string, string>> DataRefList)
{
ident = Idx;
alias = Alias;
fonte = FonteD;
dataRefList = DataRefList;
mPathAlias = new Event(string.Format("{0}_Alias", Idx));
mPathFeed = new Sample(string.Format("{0}_Feed", Idx));
mPathFeedOver = new Sample(string.Format("{0}_Feed_Over", Idx));
mPathSpeedOver = new Sample(string.Format("{0}_Speed_Over", Idx));
mPathPosActX = new Sample(string.Format("{0}_PosAct_X", Idx));
mPathPosActY = new Sample(string.Format("{0}_PosAct_Y", Idx));
mPathPosActZ = new Sample(string.Format("{0}_PosAct_Z", Idx));
mPathPosActI = new Sample(string.Format("{0}_PosAct_I", Idx));
mPathPosActJ = new Sample(string.Format("{0}_PosAct_J", Idx));
mPathPosActK = new Sample(string.Format("{0}_PosAct_K", Idx));
}
}
/// <summary>
/// Singolo mandrino, 1..n
/// </summary>
public class UnOp
{
/// <summary>
/// Id univoco
/// </summary>
protected string idx;
/// <summary>
/// Descrizione/Alias
/// </summary>
protected string descr;
/// <summary>
/// ID
/// </summary>
public Event mUnOpId;
/// <summary>
/// Alias
/// </summary>
public Event mUnOpAlias;
/// <summary>
/// Alias
/// </summary>
public Event mUnOpToolId;
/// <summary>
/// valore numero Cambi Utensili effettuato
/// </summary>
public Event mUnOpNumCU;
/// <summary>
/// status utensil
/// </summary>
public Event mUnOpStatus;
/// <summary>
/// valore vita residua utensile
/// </summary>
public Event mUnOpVitaRes;
/// <summary>
/// valore speed
/// </summary>
public Sample mUnOpSpeed;
/// <summary>
/// valore load
/// </summary>
public Sample mUnOpLoad;
/// <summary>
/// valore tempo cumulato di impiego
/// </summary>
public Sample mUnOpAccTime;
/// <summary>
/// Classe Unita Operatrice (Mandrino) con Idx e descrizione
/// </summary>
/// <param name="ident">Identificativo misura, salvato in event UnOp_{0}_Id dove {0}=ident</param>
/// <param name="alias">Alias misura, salvato in event UnOp_{0}_alias dove {0}=ident</param>
public UnOp(string ident, string alias)
{
idx = ident;
descr = alias;
mUnOpId = new Event(string.Format("UnOp_{0}_Id", idx));
mUnOpAlias = new Event(string.Format("UnOp_{0}_Alias", idx));
mUnOpToolId = new Event(string.Format("UnOp_{0}_ToolId", idx));
mUnOpNumCU = new Event(string.Format("UnOp_{0}_NumCU", idx));
mUnOpStatus = new Event(string.Format("UnOp_{0}_Status", idx));
mUnOpVitaRes = new Event(string.Format("UnOp_{0}_VitaRes", idx));
mUnOpSpeed = new Sample(string.Format("UnOp_{0}_Speed", idx));
mUnOpLoad = new Sample(string.Format("UnOp_{0}_Load", idx));
mUnOpAccTime = new Sample(string.Format("UnOp_{0}_AccTime", idx));
}
}
/// <summary>
/// Asse singolo, 1..n
/// </summary>
@@ -316,164 +461,6 @@ namespace MTC_Sim
}
/// <summary>
/// Singolo path, da 1..20
/// </summary>
public class Path
{/// <summary>
/// Id univoco
/// </summary>
protected string idx;
/// <summary>
/// Descrizione/Alias
/// </summary>
protected string descr;
/// <summary>
/// ID
/// </summary>
public Event mPathId;
/// <summary>
/// Alias
/// </summary>
public Event mPathAlias;
/// <summary>
/// Feedrate
/// </summary>
public Sample mPathFeed;
/// <summary>
/// Override feed
/// </summary>
public Sample mPathFeedOver;
/// <summary>
/// Override speed
/// </summary>
public Sample mPathSpeedOver;
/// <summary>
/// Posizione X
/// </summary>
public Sample mPathPosActX;
/// <summary>
/// Posizione Y
/// </summary>
public Sample mPathPosActY;
/// <summary>
/// Posizione Z
/// </summary>
public Sample mPathPosActZ;
/// <summary>
/// Angolo I
/// </summary>
public Sample mPathPosActI;
/// <summary>
/// Angolo J
/// </summary>
public Sample mPathPosActJ;
/// <summary>
/// Angolo K
/// </summary>
public Sample mPathPosActK;
/// <summary>
/// Classe Path con Idx e descrizione
/// </summary>
/// <param name="ident">Identificativo misura, salvato in event Path_{0}_Id dove {0}=ident</param>
/// <param name="alias">Alias misura, salvato in event Path_{0}_alias dove {0}=ident</param>
public Path(string ident, string alias)
{
idx = ident;
descr = alias;
mPathId = new Event(string.Format("Path_{0}_Id", idx));
mPathAlias = new Event(string.Format("Path_{0}_Alias", idx));
mPathFeed = new Sample(string.Format("Path_{0}_Feed", idx));
mPathFeedOver = new Sample(string.Format("Path_{0}_Feed_Over", idx));
mPathSpeedOver = new Sample(string.Format("Path_{0}_Speed_Over", idx));
mPathPosActX = new Sample(string.Format("Path_{0}_PosAct_X", idx));
mPathPosActY = new Sample(string.Format("Path_{0}_PosAct_Y", idx));
mPathPosActZ = new Sample(string.Format("Path_{0}_PosAct_Z", idx));
mPathPosActI = new Sample(string.Format("Path_{0}_PosAct_I", idx));
mPathPosActJ = new Sample(string.Format("Path_{0}_PosAct_J", idx));
mPathPosActK = new Sample(string.Format("Path_{0}_PosAct_K", idx));
}
}
/// <summary>
/// Singolo mandrino, 1..n
/// </summary>
public class UnOp
{
/// <summary>
/// Id univoco
/// </summary>
protected string idx;
/// <summary>
/// Descrizione/Alias
/// </summary>
protected string descr;
/// <summary>
/// ID
/// </summary>
public Event mUnOpId;
/// <summary>
/// Alias
/// </summary>
public Event mUnOpAlias;
/// <summary>
/// Alias
/// </summary>
public Event mUnOpToolId;
/// <summary>
/// valore numero Cambi Utensili effettuato
/// </summary>
public Event mUnOpNumCU;
/// <summary>
/// status utensil
/// </summary>
public Event mUnOpStatus;
/// <summary>
/// valore vita residua utensile
/// </summary>
public Event mUnOpVitaRes;
/// <summary>
/// valore speed
/// </summary>
public Sample mUnOpSpeed;
/// <summary>
/// valore load
/// </summary>
public Sample mUnOpLoad;
/// <summary>
/// valore tempo cumulato di impiego
/// </summary>
public Sample mUnOpAccTime;
/// <summary>
/// Classe Unita Operatrice (Mandrino) con Idx e descrizione
/// </summary>
/// <param name="ident">Identificativo misura, salvato in event UnOp_{0}_Id dove {0}=ident</param>
/// <param name="alias">Alias misura, salvato in event UnOp_{0}_alias dove {0}=ident</param>
public UnOp(string ident, string alias)
{
idx = ident;
descr = alias;
mUnOpId = new Event(string.Format("UnOp_{0}_Id", idx));
mUnOpAlias = new Event(string.Format("UnOp_{0}_Alias", idx));
mUnOpToolId = new Event(string.Format("UnOp_{0}_ToolId", idx));
mUnOpNumCU = new Event(string.Format("UnOp_{0}_NumCU", idx));
mUnOpStatus = new Event(string.Format("UnOp_{0}_Status", idx));
mUnOpVitaRes = new Event(string.Format("UnOp_{0}_VitaRes", idx));
mUnOpSpeed = new Sample(string.Format("UnOp_{0}_Speed", idx));
mUnOpLoad = new Sample(string.Format("UnOp_{0}_Load", idx));
mUnOpAccTime = new Sample(string.Format("UnOp_{0}_AccTime", idx));
}
}
#endregion
+23
View File
@@ -48,6 +48,8 @@
this.nPress = new System.Windows.Forms.TextBox();
this.label9 = new System.Windows.Forms.Label();
this.nTempe = new System.Windows.Forms.TextBox();
this.label10 = new System.Windows.Forms.Label();
this.nPath = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// txtAdapter
@@ -228,11 +230,30 @@
this.nTempe.TabIndex = 18;
this.nTempe.Text = "1";
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(314, 65);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(49, 13);
this.label10.TabIndex = 21;
this.label10.Text = "n° PATH";
//
// nPath
//
this.nPath.Location = new System.Drawing.Point(380, 62);
this.nPath.Name = "nPath";
this.nPath.Size = new System.Drawing.Size(33, 20);
this.nPath.TabIndex = 20;
this.nPath.Text = "1";
//
// SetupAdapter
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(692, 517);
this.Controls.Add(this.label10);
this.Controls.Add(this.nPath);
this.Controls.Add(this.label9);
this.Controls.Add(this.nTempe);
this.Controls.Add(this.label8);
@@ -282,5 +303,7 @@
private System.Windows.Forms.TextBox nPress;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.TextBox nTempe;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.TextBox nPath;
}
}
+45 -6
View File
@@ -111,6 +111,20 @@ namespace MTC_Sim
return answ;
}
}
int numPath
{
get
{
int answ = 0;
try
{
answ = Convert.ToInt32(nPath.Text);
}
catch
{ }
return answ;
}
}
private void btnCreateFile_Click(object sender, EventArgs e)
{
@@ -144,7 +158,7 @@ namespace MTC_Sim
element[] VacuumPump = new element[numVacPump];
// inizializzo list x parametri
listaDR =new List<DataRefItem<string, string>>();
listaDR.Add(new DataRefItem<string, string>("Status","0#8"));
listaDR.Add(new DataRefItem<string, string>("Status","0#7"));
// ciclo x istanziare!
for (int i = 0; i < numVacPump; i++)
{
@@ -161,7 +175,7 @@ namespace MTC_Sim
element[] VacuumAct = new element[numVacAct];
// inizializzo list x parametri
listaDR = new List<DataRefItem<string, string>>();
listaDR.Add(new DataRefItem<string, string>("Count", "0#16"));
listaDR.Add(new DataRefItem<string, string>("Count", "0#15"));
// ciclo x istanziare!
for (int i = 0; i < numVacAct; i++)
{
@@ -178,7 +192,7 @@ namespace MTC_Sim
element[] Lubro = new element[numLubro];
// inizializzo list x parametri
listaDR = new List<DataRefItem<string, string>>();
listaDR.Add(new DataRefItem<string, string>("Num", "0#16"));
listaDR.Add(new DataRefItem<string, string>("Num", "0#15"));
// ciclo x istanziare!
for (int i = 0; i < numLubro; i++)
{
@@ -195,7 +209,7 @@ namespace MTC_Sim
element[] Cooler = new element[numCooler];
// inizializzo list x parametri
listaDR = new List<DataRefItem<string, string>>();
listaDR.Add(new DataRefItem<string, string>("Status", "0#4"));
listaDR.Add(new DataRefItem<string, string>("Status", "0#3"));
// ciclo x istanziare!
for (int i = 0; i < numCooler; i++)
{
@@ -212,7 +226,7 @@ namespace MTC_Sim
element[] Press = new element[numPress];
// inizializzo list x parametri
listaDR = new List<DataRefItem<string, string>>();
listaDR.Add(new DataRefItem<string, string>("Value", "0#8"));
listaDR.Add(new DataRefItem<string, string>("Value", "0#7"));
// ciclo x istanziare!
for (int i = 0; i < numPress; i++)
{
@@ -229,7 +243,7 @@ namespace MTC_Sim
element[] Temp = new element[numTemp];
// inizializzo list x parametri
listaDR = new List<DataRefItem<string, string>>();
listaDR.Add(new DataRefItem<string, string>("Value", "0#8"));
listaDR.Add(new DataRefItem<string, string>("Value", "0#7"));
// ciclo x istanziare!
for (int i = 0; i < numTemp; i++)
{
@@ -238,6 +252,31 @@ namespace MTC_Sim
// salvo oggetto
c.Temp = Temp;
}
// PATH
if (numPath > 0)
{
// creo elementi richiesti
element[] Path = new element[numPath];
// inizializzo list x parametri
listaDR = new List<DataRefItem<string, string>>();
listaDR.Add(new DataRefItem<string, string>("FeedRate", "0#15"));
listaDR.Add(new DataRefItem<string, string>("FeedOverr", "16#31"));
listaDR.Add(new DataRefItem<string, string>("SpeedOverr", "32#47"));
listaDR.Add(new DataRefItem<string, string>("PosActX", "48#63"));
listaDR.Add(new DataRefItem<string, string>("PosActY", "64#79"));
listaDR.Add(new DataRefItem<string, string>("PosActZ", "80#95"));
listaDR.Add(new DataRefItem<string, string>("PosActI", "96#111"));
listaDR.Add(new DataRefItem<string, string>("PosActJ", "112#127"));
listaDR.Add(new DataRefItem<string, string>("PosActK", "128#143"));
// ciclo x istanziare!
for (int i = 0; i < numPath; i++)
{
Path[i] = new element(string.Format("Path_{0:00}", i + 1), string.Format("Path num {0}", i + 1), fonteDati.Random, listaDR);
}
// salvo oggetto
c.Path = Path;
}
// Serializzo oggetto conf su file
AdapterConf.Serialize(filePath, c);