Integration 2.1b1 :

- modifiche varie.
This commit is contained in:
Dario Sassi
2019-02-04 07:11:50 +00:00
parent 7bd36d278e
commit 0b7a91d97d
4 changed files with 771 additions and 892 deletions
+281 -301
View File
@@ -8,334 +8,314 @@ using System.Threading.Tasks;
namespace ib.essetre.integration.egaltech
{
// La classe BTL rappresenta un singolo file BTL e come esso può contenere una o più Part (ovvero le travi di legno)
// ed ogni Part può contenere una o più Feature (ovvero i tagli da effettuare)
public class BTL
{
public string projectNumber;
public string scaleUnit;
public string barLength;
public List<Part> parts;
public List<Feature> features;
//I seguenti Id servono per il nome del file BTL
public int productionId;
public int patternId;
public int projectId;
public int elementId;
public string fileName;
// La classe BTL rappresenta un singolo file BTL e come esso può contenere una o più Part (ovvero le travi di legno)
// ed ogni Part può contenere una o più Feature (ovvero i tagli da effettuare)
public class BTL
{
public string projectNumber;
public string scaleUnit;
public string barLength;
public List<Part> parts;
public List<Feature> features;
//I seguenti Id servono per il nome del file BTL
public int productionId;
public int patternId;
public int projectId;
public int elementId;
public string fileName;
public BTL()
{
public BTL()
{}
}
public BTL( string projectNumber, string scaleUnit, List<Part> parts, List<Feature> features)
{
this.projectNumber = projectNumber;
this.scaleUnit = scaleUnit;
this.parts = parts;
this.features = features;
}
public BTL(string projectNumber, string scaleUnit, List<Part> parts, List<Feature> features)
{
this.projectNumber = projectNumber;
this.scaleUnit = scaleUnit;
this.parts = parts;
this.features = features;
}
public string writeIntoFile( bool isFromProject, string dirPath)
{
// Se la directory in cui salvare il file non esiste viene creata
DirectoryInfo di = new DirectoryInfo( dirPath) ;
if ( ! di.Exists)
di.Create() ;
public string writeIntoFile(bool isFromProject, string dirPath)
{
// La directory in cui salvare il file viene qui inizializzata
DirectoryInfo di = new DirectoryInfo(dirPath);
// Se la directory non esiste viene creata
if (!di.Exists)
{
di.Create();
}
//Il nome del file cambia a seconda che si tratti del caso Produzione o caso Ordine
string typeName = null;
if (isFromProject)
{
typeName = "part";
fileName = String.Format("{0}.btl", typeName + "_" + this.projectId + "_" + this.elementId);
}
else
{
typeName = "bar";
fileName = String.Format("{0}.btl", typeName + "_" + this.productionId + "_" + this.patternId);
}
// Il nome del file cambia a seconda che si tratti del caso Produzione o caso Ordine
if ( isFromProject)
fileName = "Part_" + projectId.ToString() + "_" + elementId.ToString() + ".btl" ;
else
fileName = "Bar_" + productionId.ToString() + "_" + patternId.ToString() + ".btl";
// Si combina in un'unica stringa il percorso della directory e il nome del file da salvare
string filePath = Path.Combine(di.FullName, fileName);
// Path completa del nome del file da salvare
string filePath = Path.Combine( di.FullName, fileName) ;
// Se un file txt (contenente messaggio di errore) con lo stesso nome esiste già viene cancellato
if (File.Exists(filePath.Replace(".btl", ".txt")))
{
File.Delete(filePath.Replace(".btl", ".txt"));
}
// Se un file txt (contenente messaggio di errore) con lo stesso nome esiste già viene cancellato
if ( File.Exists( Path.ChangeExtension( filePath, ".txt")))
File.Delete( Path.ChangeExtension( filePath, ".txt")) ;
// Il seguente blocco 'using' si occupa della scrittura del file di testo, poi salvato in .btl
using (var tw = new StreamWriter(filePath, false))
{
tw.WriteLine(Constants.VERSION);
tw.WriteLine(Constants.BUILD);
tw.WriteLine(Constants.GENERAL);
tw.WriteLine(Constants.PROJECT_NUMBER + this.projectNumber);
tw.WriteLine(Constants.SCALE_UNIT + this.scaleUnit);
tw.WriteLine(Constants.USERATTRIBUTE + "\"BARLEN\":" + "\"" + this.barLength + "\"");
// Se non esistono pezzi, non faccio alcunché
if ( parts == null)
return filePath ;
foreach (Part singlePart in parts)
{
tw.WriteLine(Constants.PART);
tw.WriteLine(Constants.SINGLE_MEMBER_NUMBER + singlePart.singleMemberNumber);
tw.WriteLine(Constants.COUNT + singlePart.count);
// Il seguente blocco 'using' si occupa della scrittura del file di testo, poi salvato in .btl
using ( var tw = new StreamWriter( filePath, false)) {
double len = (Convert.ToDouble(singlePart.length)) * Math.Pow(10, Constants.scaleUnit);
int intLen = (Convert.ToInt32(len));
tw.WriteLine(Constants.LENGTH + intLen.ToString("D8"));
tw.WriteLine(Constants.VERSION);
tw.WriteLine(Constants.BUILD);
tw.WriteLine(Constants.GENERAL);
tw.WriteLine(Constants.PROJECT_NUMBER + this.projectNumber);
tw.WriteLine(Constants.SCALE_UNIT + this.scaleUnit);
tw.WriteLine(Constants.USERATTRIBUTE + "\"BARLEN\":" + "\"" + this.barLength + "\"");
double hei = (Convert.ToDouble(singlePart.height)) * Math.Pow(10, Constants.scaleUnit);
int intHei = (Convert.ToInt32(hei));
tw.WriteLine(Constants.HEIGHT + intHei.ToString("D8"));
foreach ( Part singlePart in parts) {
tw.WriteLine(Constants.PART);
tw.WriteLine(Constants.SINGLE_MEMBER_NUMBER + singlePart.singleMemberNumber);
tw.WriteLine(Constants.COUNT + singlePart.count);
double wid = (Convert.ToDouble(singlePart.width)) * Math.Pow(10, Constants.scaleUnit);
int intWid = (Convert.ToInt32(wid));
tw.WriteLine(Constants.WIDTH + intWid.ToString("D8"));
double len = (Convert.ToDouble(singlePart.length)) * Math.Pow(10, Constants.scaleUnit);
int intLen = (Convert.ToInt32(len));
tw.WriteLine(Constants.LENGTH + intLen.ToString("D8"));
string posX = singlePart.x.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture);
tw.WriteLine(Constants.USERATTRIBUTE + "\"POSX\":" + "\"" + posX + "\"");
double hei = (Convert.ToDouble(singlePart.height)) * Math.Pow(10, Constants.scaleUnit);
int intHei = (Convert.ToInt32(hei));
tw.WriteLine(Constants.HEIGHT + intHei.ToString("D8"));
string inv = singlePart.inverted.ToString();
tw.WriteLine(Constants.USERATTRIBUTE + "\"INVERTED\":" + "\"" + inv + "\"");
double wid = (Convert.ToDouble(singlePart.width)) * Math.Pow(10, Constants.scaleUnit);
int intWid = (Convert.ToInt32(wid));
tw.WriteLine(Constants.WIDTH + intWid.ToString("D8"));
string rot = singlePart.rotated.ToString();
tw.WriteLine(Constants.USERATTRIBUTE + "\"ROTATED\":" + "\"" + rot + "\"");
string posX = singlePart.x.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture);
tw.WriteLine(Constants.USERATTRIBUTE + "\"POSX\":" + "\"" + posX + "\"");
if (isFromProject)
tw.WriteLine(Constants.USERATTRIBUTE + "\"ELEMENTID\":" + "\"" + singlePart.elementId + "\"");
else
tw.WriteLine(Constants.USERATTRIBUTE + "\"CUTID\":" + "\"" + singlePart.cutId + "\"");
string inv = singlePart.inverted.ToString();
tw.WriteLine(Constants.USERATTRIBUTE + "\"INVERTED\":" + "\"" + inv + "\"");
foreach (Feature singleFeature in singlePart.features)
{
// se il processKey contiene "250" allora si tratta di un Contorno Libero e viene analizzato come tale
if (singleFeature.processKey.Contains("250"))
{
FreeContourAnalyzer(singleFeature.sag1, tw, singleFeature);
string rot = singlePart.rotated.ToString();
tw.WriteLine(Constants.USERATTRIBUTE + "\"ROTATED\":" + "\"" + rot + "\"");
if ( isFromProject)
tw.WriteLine(Constants.USERATTRIBUTE + "\"ELEMENTID\":" + "\"" + singlePart.elementId + "\"");
else
tw.WriteLine(Constants.USERATTRIBUTE + "\"CUTID\":" + "\"" + singlePart.cutId + "\"");
foreach ( Feature singleFeature in singlePart.features) {
// se il processKey contiene "250" allora si tratta di un Contorno Libero e viene analizzato come tale
if ( singleFeature.processKey.Contains( "250")) {
FreeContourAnalyzer( singleFeature.sag1, tw, singleFeature);
}
else {
tw.WriteLine( Constants.PROCESS_KEY + singleFeature.processKey + " " + singleFeature.designation);
tw.Write( Constants.PROCESS_PARAMETERS);
int i = 1 ;
foreach ( string singleParameter in singleFeature.processParameters) {
// I parametri Pnn arrivano al 26, dopo arrivano i parametri Qnn
if ( i < 27) {
// Stampo i vari parametri Pnn
if ( i != 15 || ! (singleFeature.processKey.Contains("060") || singleFeature.processKey.Contains("061")))
tw.Write("P" + i.ToString("D2") + ":" + MultAndConvertTo8(singleParameter) + " ");
else
tw.Write("P" + i.ToString("D2") + ":" + "\"" + singleParameter + "\" ");
if ( i == 26)
tw.WriteLine(" "); // Vado a capo
}
else
{
tw.WriteLine(Constants.PROCESS_KEY + singleFeature.processKey + " " + singleFeature.designation);
tw.Write(Constants.PROCESS_PARAMETERS);
int i = 1;
foreach (string singleParameter in singleFeature.processParameters)
{
if (i < 27) // I parametri Pnn arrivano al 26, dopo arrivano i parametri Qnn
{
// Stampo i vari parametri Pnn
if (i != 15)
tw.Write("P" + i.ToString("D2") + ":" + MultAndConvertTo8(singleParameter) + " ");
else
tw.Write("P" + i.ToString("D2") + ":" + "\"\" "); // P15: ""
if (i == 26)
tw.WriteLine(" "); // Vado a capo
}
else
{
// Stampo i vari parametri Qnn diversi da 0, preceduti da "USERATTRIBUTE:"
if (!singleParameter.Equals("0"))
{
string rp = singleParameter.Replace(",", ".");
tw.WriteLine(Constants.USERATTRIBUTE + "\"Q" + (i - 26).ToString("D2") + "\":\"" + singleParameter + "\" ");
}
}
//Convert.ToInt16(i);
i++;
}
tw.WriteLine(Constants.PROCESS_IDENT + singleFeature.processIdent);
tw.WriteLine(Constants.PROCESS + singleFeature.process);
else {
// Stampo i vari parametri Qnn diversi da 0, preceduti da "USERATTRIBUTE:"
if ( ! singleParameter.Equals( "0")) {
string rp = singleParameter.Replace(",", ".");
tw.WriteLine(Constants.USERATTRIBUTE + "\"Q" + (i - 26).ToString("D2") + "\":\"" + singleParameter + "\" ");
}
}
i++;
}
if (isFromProject)
tw.WriteLine(Constants.USERATTRIBUTE + "\"PROCESSID\":" + "\"" + singleFeature.processId + "\"");
else
tw.WriteLine(Constants.USERATTRIBUTE + "\"TASKID\":" + "\"" + singleFeature.taskId + "\"");
tw.WriteLine(Constants.PROCESS_IDENT + singleFeature.processIdent);
tw.WriteLine(Constants.PROCESS + singleFeature.process);
}
}
}
if ( isFromProject)
tw.WriteLine(Constants.USERATTRIBUTE + "\"PROCESSID\":" + "\"" + singleFeature.processId + "\"");
else
tw.WriteLine(Constants.USERATTRIBUTE + "\"TASKID\":" + "\"" + singleFeature.taskId + "\"");
}
}
return filePath;
}
}
return filePath;
}
// Il seguente metodo analizza il campo sag1 della singleFeature passata: se non è vuoto allora la stringa
// viene splittata nei parametri P di POLY ed analizzata
public void FreeContourAnalyzer(string sag1, StreamWriter tw, Feature singleFeature)
{
if (sag1 != "")
{
string[] arrParam = sag1.Split(new string[] { "POLY([", "),", ")],'P','O')" }, StringSplitOptions.RemoveEmptyEntries);
// Il seguente metodo analizza il campo sag1 della singleFeature passata: se non è vuoto allora la stringa
// viene splittata nei parametri P di POLY ed analizzata
public void FreeContourAnalyzer(string sag1, StreamWriter tw, Feature singleFeature)
{
if ( sag1 == "")
return ;
if (singleFeature.processParameters[37].Equals(1)) // Se il parametro Q10 è 1, l'ordine dell'array viene invertito
Array.Reverse(arrParam);
string[] arrParam = sag1.Split(new string[] { "POLY([", "),", ")],'P','O')" }, StringSplitOptions.RemoveEmptyEntries);
int count = 0; // Nel caso in cui ci troviamo alla fine di un Arco questa viene incrementata di 1, in modo da scrivere il numero parametro corretto nei seguenti cicli
Boolean flagArco = false; // Nel caso in cui ci troviamo all'inizio di un Arco questa viene posta a TRUE, in modo da passare nel percorso dedicato nel prossimo ciclo
for (int i = 0; i < arrParam.Length; i++)
{
char[] separators = { ',', '(' };
string[] parts = arrParam[i].Split(separators); // ogni parametro P di POLY viene splittato in più parti
switch (parts[0]) // il primo elemento di parts[] indica se ci troviamo all'inizio di un Arco o no
{
case "P":
if (i == 0) // Caso StartPoint
{
tw.WriteLine(Constants.PROCESS_KEY + singleFeature.processKey + " " + singleFeature.designation);
tw.Write(Constants.PROCESS_PARAMETERS);
tw.Write("P01:" + MultAndConvertTo8(parts[1]) + " "); // x
tw.Write("P02:" + MultAndConvertTo8(parts[2]) + " "); // y
tw.Write("P03:" + MultAndConvertTo8(parts[3]) + " "); // z
tw.Write("P05:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P06:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P07:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P08:" + Constants.EIGHT_ZEROS + " ");
if (i == arrParam.Length - 1) // Verifica se ci troviamo all'ultimo parametro di POLY
tw.Write("P09:" + Constants.EIGHT_ZEROS + " "); // L'ultimo elemento di POLY deve avere "P09: 00000000"
else
tw.Write("P09:" + MultAndConvertTo8((Convert.ToDouble(singleFeature.processParameters[8]) + i - count).ToString()) + " ");
tw.Write("P10:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P11:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P12:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P13:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P14:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P15:" + Constants.EIGHT_ZEROS + " ");
tw.WriteLine(" ");
tw.WriteLine(Constants.PROCESS_IDENT + (Convert.ToInt16(singleFeature.processIdent) + i - count));
tw.WriteLine(Constants.PROCESS + singleFeature.process);
}
else if (flagArco) // Caso FineArco
{
count++;
flagArco = false;
}
else // Caso StraightLine
{
tw.WriteLine(Constants.PROCESS_KEY + singleFeature.processKey + " " + singleFeature.designation);
tw.Write(Constants.PROCESS_PARAMETERS);
tw.Write("P01:" + MultAndConvertTo8(parts[1]) + " "); // x
tw.Write("P02:" + MultAndConvertTo8(parts[2]) + " "); // y
tw.Write("P03:" + MultAndConvertTo8(parts[3]) + " "); // z
tw.Write("P05:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P06:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P07:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P08:" + "00000100" + " ");
if (i == arrParam.Length - 1)
tw.Write("P09:" + Constants.EIGHT_ZEROS + " ");
else
tw.Write("P09:" + MultAndConvertTo8((Convert.ToDouble(singleFeature.processParameters[8]) + i - count).ToString()) + " ");
tw.Write("P10:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P11:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P12:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P13:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P14:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P15:" + Constants.EIGHT_ZEROS + " ");
tw.WriteLine(" ");
tw.WriteLine(Constants.PROCESS_IDENT + (Convert.ToInt16(singleFeature.processIdent) + i - count));
tw.WriteLine(Constants.PROCESS + singleFeature.process);
}
break;
case "A": // Caso InizioArco
tw.WriteLine(Constants.PROCESS_KEY + singleFeature.processKey + " " + singleFeature.designation);
tw.Write(Constants.PROCESS_PARAMETERS);
string[] nextParts = arrParam[i + 1].Split(separators);
tw.Write("P01:" + MultAndConvertTo8(nextParts[1]) + " "); // x (EndPoint Arc)
tw.Write("P02:" + MultAndConvertTo8(nextParts[2]) + " "); // y (EndPoint Arc)
tw.Write("P03:" + MultAndConvertTo8(nextParts[3]) + " "); // z (Endpoint Arc)
tw.Write("P05:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P06:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P07:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P08:" + "00000200" + " ");
if (i == arrParam.Length - 1)
tw.Write("P09:" + Constants.EIGHT_ZEROS + " ");
else
tw.Write("P09:" + MultAndConvertTo8((Convert.ToDouble(singleFeature.processParameters[8]) + i - count).ToString()) + " ");
tw.Write("P10:" + MultAndConvertTo8(parts[1]) + " "); // x (Point on Arc)
tw.Write("P11:" + MultAndConvertTo8(parts[2]) + " "); // y (Point on Arc)
tw.Write("P12:" + MultAndConvertTo8(parts[3]) + " "); // z (Point on Arc)
tw.Write("P13:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P14:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P15:" + Constants.EIGHT_ZEROS + " ");
tw.WriteLine(" ");
tw.WriteLine(Constants.PROCESS_IDENT + (Convert.ToInt16(singleFeature.processIdent) + i - count));
tw.WriteLine(Constants.PROCESS + singleFeature.process);
flagArco = true;
break;
default:
tw.WriteLine(Constants.PROCESS_KEY + singleFeature.processKey + " " + singleFeature.designation);
tw.Write(Constants.PROCESS_PARAMETERS);
tw.Write("P01:" + MultAndConvertTo8(parts[1]) + " ");
tw.Write("P02:" + MultAndConvertTo8(parts[2]) + " ");
tw.Write("P03:" + MultAndConvertTo8(parts[3]) + " ");
tw.Write("P05:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P06:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P07:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P08:" + Constants.EIGHT_ZEROS + " ");
if (i == arrParam.Length - 1)
tw.Write("P09:" + Constants.EIGHT_ZEROS + " ");
else
tw.Write("P09:" + MultAndConvertTo8((Convert.ToDouble(singleFeature.processParameters[8]) + i - count).ToString()) + " ");
tw.Write("P10:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P11:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P12:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P13:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P14:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P15:" + Constants.EIGHT_ZEROS + " ");
tw.WriteLine(" ");
tw.WriteLine(Constants.PROCESS_IDENT + (Convert.ToInt16(singleFeature.processIdent) + i - count));
tw.WriteLine(Constants.PROCESS + singleFeature.process);
break;
}
}
// Se il parametro Q10 è 1, l'ordine dell'array viene invertito
if ( singleFeature.processParameters[37].Equals(1))
Array.Reverse( arrParam) ;
int count = 0; // Nel caso in cui ci troviamo alla fine di un Arco questa viene incrementata di 1, in modo da scrivere il numero parametro corretto nei seguenti cicli
Boolean flagArco = false; // Nel caso in cui ci troviamo all'inizio di un Arco questa viene posta a TRUE, in modo da passare nel percorso dedicato nel prossimo ciclo
for (int i = 0; i < arrParam.Length; i++) {
char[] separators = { ',', '(' };
string[] parts = arrParam[i].Split(separators); // ogni parametro P di POLY viene splittato in più parti
// il primo elemento di parts[] indica se ci troviamo all'inizio di un Arco o no
switch (parts[0]) {
case "P":
// Se StartPoint
if ( i == 0) {
tw.WriteLine(Constants.PROCESS_KEY + singleFeature.processKey + " " + singleFeature.designation);
tw.Write(Constants.PROCESS_PARAMETERS);
tw.Write("P01:" + MultAndConvertTo8(parts[1]) + " "); // x
tw.Write("P02:" + MultAndConvertTo8(parts[2]) + " "); // y
tw.Write("P03:" + MultAndConvertTo8(parts[3]) + " "); // z
tw.Write("P05:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P06:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P07:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P08:" + Constants.EIGHT_ZEROS + " ");
if ( i == arrParam.Length - 1) // Verifica se ci troviamo all'ultimo parametro di POLY
tw.Write("P09:" + Constants.EIGHT_ZEROS + " "); // L'ultimo elemento di POLY deve avere "P09: 00000000"
else
tw.Write("P09:" + MultAndConvertTo8((Convert.ToDouble(singleFeature.processParameters[8]) + i - count).ToString()) + " ");
tw.Write("P10:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P11:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P12:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P13:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P14:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P15:" + Constants.EIGHT_ZEROS + " ");
tw.WriteLine(" ");
tw.WriteLine(Constants.PROCESS_IDENT + (Convert.ToInt16(singleFeature.processIdent) + i - count));
tw.WriteLine(Constants.PROCESS + singleFeature.process);
}
// altrimenti se FineArco
else if ( flagArco) {
count++;
flagArco = false ;
}
// altrimenti FineSegmento
else {
tw.WriteLine(Constants.PROCESS_KEY + singleFeature.processKey + " " + singleFeature.designation);
tw.Write(Constants.PROCESS_PARAMETERS);
tw.Write("P01:" + MultAndConvertTo8(parts[1]) + " "); // x
tw.Write("P02:" + MultAndConvertTo8(parts[2]) + " "); // y
tw.Write("P03:" + MultAndConvertTo8(parts[3]) + " "); // z
tw.Write("P05:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P06:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P07:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P08:" + "00000100" + " ");
if ( i == arrParam.Length - 1)
tw.Write("P09:" + Constants.EIGHT_ZEROS + " ");
else
tw.Write("P09:" + MultAndConvertTo8((Convert.ToDouble(singleFeature.processParameters[8]) + i - count).ToString()) + " ");
tw.Write("P10:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P11:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P12:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P13:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P14:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P15:" + Constants.EIGHT_ZEROS + " ");
tw.WriteLine(" ");
tw.WriteLine(Constants.PROCESS_IDENT + (Convert.ToInt16(singleFeature.processIdent) + i - count));
tw.WriteLine(Constants.PROCESS + singleFeature.process);
}
break;
case "A": // Caso InizioArco
tw.WriteLine(Constants.PROCESS_KEY + singleFeature.processKey + " " + singleFeature.designation);
tw.Write(Constants.PROCESS_PARAMETERS);
string[] nextParts = arrParam[i + 1].Split(separators);
tw.Write("P01:" + MultAndConvertTo8(nextParts[1]) + " "); // x (EndPoint Arc)
tw.Write("P02:" + MultAndConvertTo8(nextParts[2]) + " "); // y (EndPoint Arc)
tw.Write("P03:" + MultAndConvertTo8(nextParts[3]) + " "); // z (Endpoint Arc)
tw.Write("P05:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P06:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P07:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P08:" + "00000200" + " ");
if ( i == arrParam.Length - 1)
tw.Write("P09:" + Constants.EIGHT_ZEROS + " ");
else
tw.Write("P09:" + MultAndConvertTo8((Convert.ToDouble(singleFeature.processParameters[8]) + i - count).ToString()) + " ");
tw.Write("P10:" + MultAndConvertTo8(parts[1]) + " "); // x (Point on Arc)
tw.Write("P11:" + MultAndConvertTo8(parts[2]) + " "); // y (Point on Arc)
tw.Write("P12:" + MultAndConvertTo8(parts[3]) + " "); // z (Point on Arc)
tw.Write("P13:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P14:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P15:" + Constants.EIGHT_ZEROS + " ");
tw.WriteLine(" ");
tw.WriteLine(Constants.PROCESS_IDENT + (Convert.ToInt16(singleFeature.processIdent) + i - count));
tw.WriteLine(Constants.PROCESS + singleFeature.process);
flagArco = true;
break;
default:
tw.WriteLine(Constants.PROCESS_KEY + singleFeature.processKey + " " + singleFeature.designation);
tw.Write(Constants.PROCESS_PARAMETERS);
tw.Write("P01:" + MultAndConvertTo8(parts[1]) + " ");
tw.Write("P02:" + MultAndConvertTo8(parts[2]) + " ");
tw.Write("P03:" + MultAndConvertTo8(parts[3]) + " ");
tw.Write("P05:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P06:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P07:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P08:" + Constants.EIGHT_ZEROS + " ");
if ( i == arrParam.Length - 1)
tw.Write("P09:" + Constants.EIGHT_ZEROS + " ");
else
tw.Write("P09:" + MultAndConvertTo8((Convert.ToDouble(singleFeature.processParameters[8]) + i - count).ToString()) + " ");
tw.Write("P10:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P11:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P12:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P13:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P14:" + Constants.EIGHT_ZEROS + " ");
tw.Write("P15:" + Constants.EIGHT_ZEROS + " ");
tw.WriteLine(" ");
tw.WriteLine(Constants.PROCESS_IDENT + (Convert.ToInt16(singleFeature.processIdent) + i - count));
tw.WriteLine(Constants.PROCESS + singleFeature.process);
break;
}
}
}
}
// Il seguente metodo prende il valore di un Process Parameter, lo moltiplica per 10^scaleUnit
// e lo converte in una stringa di 8 caratteri (i caratteri mancanti sono degli 0)
public string MultAndConvertTo8(string processParameter)
{
double sp = 0;
string rp = processParameter.Replace(",", ".");
sp = (Convert.ToDouble(rp, CultureInfo.InvariantCulture)) * Math.Pow(10, Constants.scaleUnit);
int intSp = (Convert.ToInt32(sp));
string s8 = intSp.ToString("D8");
return s8;
}
// Il seguente metodo prende il valore di un Process Parameter, lo moltiplica per 10^scaleUnit
// e lo converte in una stringa di 8 caratteri (i caratteri mancanti sono degli 0)
public string MultAndConvertTo8(string processParameter)
{
double sp = 0;
string rp = processParameter.Replace(",", ".");
sp = (Convert.ToDouble(rp, CultureInfo.InvariantCulture)) * Math.Pow(10, Constants.scaleUnit);
int intSp = (Convert.ToInt32(sp));
string s8 = intSp.ToString("D8");
return s8;
}
// Le 2 seguenti struct dichiarano i campi necessari alla costruzione di una Part e di una Feature
public struct Part
{
public string singleMemberNumber;
public string count;
public string length;
public string height;
public string width;
public List<Feature> features;
public double x;
public string inverted;
public string rotated;
public int elementId;
public int cutId;
}
public struct Feature
{
public string taskId;
public string processKey;
public string designation;
public List<string> processParameters;
public string processIdent;
public string process;
public string sag1;
public string processId;
}
// Le 2 seguenti struct dichiarano i campi necessari alla costruzione di una Part e di una Feature
public struct Part
{
public string singleMemberNumber;
public string count;
public string length;
public string height;
public string width;
public List<Feature> features;
public double x;
public string inverted;
public string rotated;
public int elementId;
public int cutId;
}
public struct Feature
{
public string taskId;
public string processKey;
public string designation;
public List<string> processParameters;
public string processIdent;
public string process;
public string sag1;
public string processId;
}
}
}
File diff suppressed because it is too large Load Diff
@@ -18,14 +18,14 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>C:\TechnoEssetre7\</OutputPath>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>
@@ -5,12 +5,12 @@ using System.Runtime.InteropServices;
// Le informazioni generali relative a un assembly sono controllate dal seguente
// set di attributi. Modificare i valori di questi attributi per modificare le informazioni
// associate a un assembly.
[assembly: AssemblyTitle("IntegrationEgaltech")]
#if DEBUG
[assembly: AssemblyDescription("IntegrationEgaltech Debug")]
[assembly: AssemblyTitle("IntegrationEgaltech Debug")]
#else
[assembly: AssemblyDescription("IntegrationEgaltech")]
[assembly: AssemblyTitle("IntegrationEgaltech")]
#endif
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("EgalTech s.r.l.")]
[assembly: AssemblyProduct("IntegrationEgaltech")]
@@ -36,5 +36,5 @@ using System.Runtime.InteropServices;
// È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build
// usando l'asterisco '*' come illustrato di seguito:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.1.1.5")]
[assembly: AssemblyFileVersion("2.1.1.5")]
[assembly: AssemblyVersion("2.1.2.1")]
[assembly: AssemblyFileVersion("2.1.2.1")]