diff --git a/IntegrationEgaltech/BTL.cs b/IntegrationEgaltech/BTL.cs index e8b7ab5..804c8ea 100644 --- a/IntegrationEgaltech/BTL.cs +++ b/IntegrationEgaltech/BTL.cs @@ -82,13 +82,40 @@ namespace ib.essetre.integration.egaltech string CutId = ( IsFromProject ? singlePart.elementId : singlePart.cutId).ToString() ; tw.WriteLine( Constants.USERATTRIBUTE + "\"CUTID\":" + "\"" + CutId + "\"") ; + // Scrivo eventuale Outline + foreach ( Feature singleFeature in singlePart.features) { + // Assegno identificativo del processo + string TaskId = (IsFromProject ? singleFeature.processId : singleFeature.taskId).ToString() ; + // Se Outline (processo "251") elaborazione speciale + if ( singleFeature.processKey.Contains( "251")) { + WriteOutlineAperture( true, singleFeature, TaskId, tw) ; + } + } + + // Scrivo eventuali Aperture + foreach ( Feature singleFeature in singlePart.features) { + // Assegno identificativo del processo + string TaskId = (IsFromProject ? singleFeature.processId : singleFeature.taskId).ToString() ; + // Se Aperture (processo "252") elaborazione speciale + if ( singleFeature.processKey.Contains( "252")) { + WriteOutlineAperture( false, singleFeature, TaskId, tw) ; + } + } + + // Scrivo tutti gli altri processi foreach ( Feature singleFeature in singlePart.features) { // Assegno identificativo del processo string TaskId = ( IsFromProject ? singleFeature.processId : singleFeature.taskId).ToString() ; - // Se Contorno Libero (processo "250") elaborazione speciale - if ( singleFeature.processKey.Contains( "250")) { + // Se Outline (processo "251") o Aperture (processo "252") salto + if ( singleFeature.processKey.Contains( "251") || + singleFeature.processKey.Contains( "252")) { + ; + } + // Se Free Contour (processo "250") elaborazione speciale + else if ( singleFeature.processKey.Contains( "250")) { WriteFreeContour( singleFeature, TaskId, tw) ; } + // Altri processi else { // Tipo di Process tw.WriteLine( Constants.PROCESS_KEY + singleFeature.processKey + " " + singleFeature.designation) ; @@ -129,6 +156,105 @@ namespace ib.essetre.integration.egaltech return true ; } + // 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 WriteOutlineAperture( bool bOutline, Feature singleFeature, String TaskId, StreamWriter tw) + { + // Se non ci sono dati, esco + if (singleFeature.sag1 == "") + return; + + // Divido i dati in record punti + string[] arrParam = singleFeature.sag1.Split(new string[] { "POLY([", "),", ")]" }, StringSplitOptions.RemoveEmptyEntries); + + // Se curva chiusa, copio il primo punto nell'ultimo elemento + if ( arrParam[arrParam.Length - 1] == ",'P','C')") + arrParam[arrParam.Length - 1] = arrParam[0]; + // altrimenti aperta, quindi elimino l'ultimo elemento + else + Array.Resize( ref arrParam, arrParam.Length - 1); + + // Se il parametro Q10 è 1, l'ordine dell'array viene invertito + if ( singleFeature.processParameters[35] == "1") + Array.Reverse(arrParam); + + // Recupero il lato di lavoro + string sSide = singleFeature.processKey.Substring( Math.Max( 0, singleFeature.processKey.Length - 1)) ; + + // Ciclo sugli elementi + Boolean flagArco = false ; + 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": + default: + // Se StartPoint + if ( i == 0) { + tw.Write( ( bOutline ? Constants.OUTLINE_KEY : Constants.APERTURE_KEY)) ; + tw.Write( Constants.SIDE + sSide + " ") ; + tw.Write( Constants.PROCESS + singleFeature.process + " ") ; + tw.Write( "P01:" + MultAndConvertTo8(parts[1]) + " "); // x + tw.Write( "P02:" + MultAndConvertTo8(parts[2]) + " "); // y + tw.Write( "P03:" + MultAndConvertTo8(parts[3]) + " "); // z + tw.Write( "P06:" + Constants.EIGHT_ZEROS + " "); + tw.Write( "P08:" + Constants.EIGHT_ZEROS + " "); + tw.Write( "P10:" + Constants.EIGHT_ZEROS + " "); + tw.Write( "P11:" + Constants.EIGHT_ZEROS + " "); + tw.Write( "P12:" + Constants.EIGHT_ZEROS + " "); + tw.WriteLine( " "); + // Parametri speciali Q diversi da 0, preceduti da "USERATTRIBUTE:" + for ( int j = 1; j <= 20; ++j) { + string singleParameter = singleFeature.processParameters[j + 25]; + if ( ! singleParameter.Equals( "0")) { + singleParameter = singleParameter.Replace( ",", "."); + tw.WriteLine( Constants.USERATTRIBUTE + "\"Q" + j.ToString( "D2") + "\":\"" + singleParameter + "\" "); + } + } + // TaskId + tw.WriteLine(Constants.USERATTRIBUTE + "\"TASKID\":" + "\"" + TaskId + "\""); + } + // se altrimenti FineArco + else if ( flagArco) { + tw.Write( ( bOutline ? Constants.OUTLINE_KEY : Constants.APERTURE_KEY)) ; + tw.Write( Constants.SIDE + sSide + " ") ; + tw.Write( Constants.PROCESS + singleFeature.process + " ") ; + tw.Write( "P01:" + MultAndConvertTo8(parts[1]) + " "); // x (EndPoint Arc) + tw.Write( "P02:" + MultAndConvertTo8(parts[2]) + " "); // y (EndPoint Arc) + tw.Write( "P03:" + MultAndConvertTo8(parts[3]) + " "); // z (Endpoint Arc) + tw.Write( "P06:" + Constants.EIGHT_ZEROS + " "); + tw.Write( "P08:" + "00000200" + " "); + string[] PrevParts = arrParam[i - 1].Split(separators); + tw.Write( "P10:" + MultAndConvertTo8(PrevParts[1]) + " "); // x (Point on Arc) + tw.Write( "P11:" + MultAndConvertTo8(PrevParts[2]) + " "); // y (Point on Arc) + tw.Write( "P12:" + MultAndConvertTo8(PrevParts[3]) + " "); // z (Point on Arc) + tw.WriteLine( " "); + flagArco = false; + } + // altrimenti FineSegmento + else { + tw.Write( ( bOutline ? Constants.OUTLINE_KEY : Constants.APERTURE_KEY)) ; + tw.Write( Constants.SIDE + sSide + " ") ; + tw.Write( Constants.PROCESS + singleFeature.process + " ") ; + tw.Write( "P01:" + MultAndConvertTo8(parts[1]) + " "); // x + tw.Write( "P02:" + MultAndConvertTo8(parts[2]) + " "); // y + tw.Write( "P03:" + MultAndConvertTo8(parts[3]) + " "); // z + tw.Write( "P06:" + Constants.EIGHT_ZEROS + " "); + tw.Write( "P08:" + "00000100" + " "); + tw.Write( "P10:" + Constants.EIGHT_ZEROS + " "); + tw.Write( "P11:" + Constants.EIGHT_ZEROS + " "); + tw.Write( "P12:" + Constants.EIGHT_ZEROS + " "); + tw.WriteLine( " "); + } + break; + case "A": // InizioArco + flagArco = true; + break; + } + } + } + // 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 WriteFreeContour( Feature singleFeature, String TaskId, StreamWriter tw) diff --git a/IntegrationEgaltech/Constants.cs b/IntegrationEgaltech/Constants.cs index bec1502..4d6c271 100644 --- a/IntegrationEgaltech/Constants.cs +++ b/IntegrationEgaltech/Constants.cs @@ -21,7 +21,10 @@ namespace ib.essetre.integration.egaltech public const string LENGTH = "LENGTH: " ; public const string HEIGHT = "HEIGHT: " ; public const string WIDTH = "WIDTH: " ; - public const string PROCESS_KEY = "PROCESSKEY: " ; + public const string OUTLINE_KEY = "OUTLINE: "; + public const string APERTURE_KEY = "APERTURE: "; + public const string SIDE = "SIDE: "; + public const string PROCESS_KEY = "PROCESSKEY: "; public const string PROCESS_PARAMETERS = "PROCESSPARAMETERS: " ; public const string REFERENCE_PLANE = "REFERENCEPLANE: " ; public const string PROCESS_IDENT = "PROCESSIDENT: " ; diff --git a/IntegrationEgaltech/Properties/AssemblyInfo.cs b/IntegrationEgaltech/Properties/AssemblyInfo.cs index b27b306..edd4c1f 100644 --- a/IntegrationEgaltech/Properties/AssemblyInfo.cs +++ b/IntegrationEgaltech/Properties/AssemblyInfo.cs @@ -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.2.5.1")] -[assembly: AssemblyFileVersion("2.2.5.1")] +[assembly: AssemblyVersion("2.2.6.1")] +[assembly: AssemblyFileVersion("2.2.6.1")]