diff --git a/IntegrationEgaltech/BTL.cs b/IntegrationEgaltech/BTL.cs index 34171c1..ba710e6 100644 --- a/IntegrationEgaltech/BTL.cs +++ b/IntegrationEgaltech/BTL.cs @@ -302,10 +302,29 @@ namespace ib.essetre.integration.egaltech // Se non ci sono dati, esco if ( singleFeature.sag1 == "") return ; + // Verifico se c'è un secondo percorso + bool bTwo = ( singleFeature.sag2 != "") ; + // Se singolo contorno + if ( ! bTwo) { + string[] arrParam = singleFeature.sag1.Split( new string[] { "POLY([", "),", ")]" }, StringSplitOptions.RemoveEmptyEntries) ; + AdjustContourArray( singleFeature, ref arrParam) ; + WriteOneContour( singleFeature, ref arrParam, TaskId, 0, tw) ; + } + // altrimenti due contorni + if ( bTwo) { + // Primo contorno + string[] arrParam = singleFeature.sag1.Split( new string[] { "POLY([", "),", ")]" }, StringSplitOptions.RemoveEmptyEntries) ; + AdjustContourArray( singleFeature, ref arrParam) ; + WriteOneContour( singleFeature, ref arrParam, TaskId, 1, tw) ; + // Secondo contorno + string[] arrParam2 = singleFeature.sag2.Split( new string[] { "POLY([", "),", ")]" }, StringSplitOptions.RemoveEmptyEntries) ; + AdjustContourArray( singleFeature, ref arrParam2) ; + WriteOneContour( singleFeature, ref arrParam2, TaskId, 2, tw) ; + } + } - // Divido i dati in record punti - string[] arrParam = singleFeature.sag1.Split( new string[] { "POLY([", "),", ")]" }, StringSplitOptions.RemoveEmptyEntries) ; - + private void AdjustContourArray( Feature singleFeature, ref string[] arrParam) + { // Se curva chiusa if ( arrParam[arrParam.Length - 1] == ",'P','C')") { // se primo punto è a metà di arco, copio l'ultimo punto inserendolo prima del primo @@ -326,13 +345,28 @@ namespace ib.essetre.integration.egaltech else Array.Resize( ref arrParam, arrParam.Length-1) ; - // Se il parametro Q10 è 1, l'ordine dell'array viene invertito + // Se il parametro Q10 è 1, l'ordine dell'array viene invertito if ( singleFeature.processParameters[35] == "1") Array.Reverse( arrParam) ; + } + private int GetContourArrayCount( ref string[] arrParam) + { + int nCount = 0 ; + 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 + if ( parts[0] != "A") + nCount ++ ; + } + return nCount ; + } + + private void WriteOneContour( Feature singleFeature, ref string[] arrParam, String TaskId, int nInd, StreamWriter tw) + { // Ciclo sugli elementi Boolean flagArco = false ; - for (int i = 0; i < arrParam.Length; i++) { + 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 @@ -349,10 +383,18 @@ namespace ib.essetre.integration.egaltech tw.Write("P01:" + MultAndConvertTo8(parts[1]) + " "); // x tw.Write("P02:" + MultAndConvertTo8(parts[2]) + " "); // y tw.Write("P03:" + MultAndConvertTo8(parts[3]) + " "); // z - tw.Write("P05:" + MultAndConvertTo8(singleFeature.processParameters[4]) + " "); - tw.Write("P06:" + Constants.EIGHT_ZEROS + " "); + tw.Write("P05:" + MultAndConvertTo8(singleFeature.processParameters[4]) + " ") ; + if ( nInd == 0) + tw.Write("P06:" + Constants.EIGHT_ZEROS + " ") ; + else if ( nInd == 1) + tw.Write("P06:" + MultAndConvertTo8( (_FcEnt + GetContourArrayCount( ref arrParam))) + " ") ; + else + tw.Write("P06:" + MultAndConvertTo8( (_FcEnt - GetContourArrayCount( ref arrParam))) + " ") ; tw.Write("P07:" + MultAndConvertTo8(singleFeature.processParameters[6]) + " "); - tw.Write("P08:" + Constants.EIGHT_ZEROS + " "); + if ( nInd == 0) + tw.Write("P08:" + _FcEnt + " "); + else + tw.Write("P08:" + MultAndConvertTo8( ( nInd == 1 ? "100" : "101")) + " "); 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 @@ -366,16 +408,19 @@ namespace ib.essetre.integration.egaltech tw.WriteLine(" "); tw.WriteLine(Constants.PROCESS_IDENT + _FcEnt.ToString()); tw.WriteLine(Constants.PROCESS + singleFeature.process); - // 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 + "\" ") ; + // Se unico o primo contorno + if ( nInd == 0 || nInd == 1) { + // 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 + "\"") ; } - // TaskId - tw.WriteLine( Constants.USERATTRIBUTE + "\"TASKID\":" + "\"" + TaskId + "\"") ; } // se altrimenti FineArco else if ( flagArco) { @@ -489,6 +534,14 @@ namespace ib.essetre.integration.egaltech return s8 ; } + public string MultAndConvertTo8( double dVal) + { + double sp = dVal * 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 { @@ -519,6 +572,7 @@ namespace ib.essetre.integration.egaltech public string processIdent ; public string process ; public string sag1 ; + public string sag2 ; public string text ; public string processId ; } diff --git a/IntegrationEgaltech/Generator.cs b/IntegrationEgaltech/Generator.cs index 3661dce..5638c9f 100644 --- a/IntegrationEgaltech/Generator.cs +++ b/IntegrationEgaltech/Generator.cs @@ -100,7 +100,7 @@ namespace ib.essetre.integration.egaltech "p01, p02, p03, p04, p05, p06, p07, p08, p09, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, " + "q01, q02, q03, q04, q05, q06, q07, q08, q09, q10, q11, q12, q13, q14, q15, q16, q17, q18, q19, q20, " + "ox, oy, oz, xx, xy, xz, yx, yy, yz, " + - "priority, processIdent, processingQuality, sag1, text, E.projectId, E.elementId, P.processId, 0 cutStart, 0 cutEnd, " + + "priority, processIdent, processingQuality, sag1, sag2, text, E.projectId, E.elementId, P.processId, 0 cutStart, 0 cutEnd, " + "E.inverted, E.rotated, 0 startAngle, 0 endAngle, -1 referenceCutId, E.length, E.width, E.height " + "FROM dbo.vw_Process AS P " + "RIGHT OUTER JOIN dbo.vw_Element AS E " + @@ -115,7 +115,7 @@ namespace ib.essetre.integration.egaltech "p01, p02, p03, p04, p05, p06, p07, p08, p09, p10, p11, p12, p13, p14, p15, p16, p17, p18, p19, p20, p21, p22, p23, p24, p25, p26, " + "q01, q02, q03, q04, q05, q06, q07, q08, q09, q10, q11, q12, q13, q14, q15, q16, q17, q18, q19, q20, " + "ox, oy, oz, xx, xy, xz, yx, yy, yz, " + - "priority, processIdent, processingQuality, sag1, text, vw_Cut.projectId, vw_Cut.elementId, cutStart, cutEnd, " + + "priority, processIdent, processingQuality, sag1, sag2, text, vw_Cut.projectId, vw_Cut.elementId, cutStart, cutEnd, " + "inverted, rotated, startAngle, endAngle, referenceCutId, length, width, height " + "FROM dbo.vw_Task " + "RIGHT OUTER JOIN dbo.vw_Cut " + @@ -621,6 +621,7 @@ namespace ib.essetre.integration.egaltech designation = dRowF["des"].ToString(), processIdent = dRowF["processIdent"].ToString(), sag1 = dRowF["sag1"].ToString(), + sag2 = dRowF["sag2"].ToString(), text = dRowF["text"].ToString(), process = ( Convert.ToInt16( dRowF["enabled"]) == 1) ? "YES" : "NO", processParameters = new List( 46) { @@ -770,6 +771,7 @@ namespace ib.essetre.integration.egaltech designation = dRowF["des"].ToString(), processIdent = dRowF["processIdent"].ToString(), sag1 = dRowF["sag1"].ToString(), + sag2 = dRowF["sag2"].ToString(), text = dRowF["text"].ToString(), process = ( Convert.ToInt16( dRowF["enabled"]) == 1) ? "YES" : "NO", processParameters = new List( 46) { diff --git a/IntegrationEgaltech/Properties/AssemblyInfo.cs b/IntegrationEgaltech/Properties/AssemblyInfo.cs index 91788c0..394039e 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.3.9.1")] -[assembly: AssemblyFileVersion("2.3.9.1")] +[assembly: AssemblyVersion("2.3.10.1")] +[assembly: AssemblyFileVersion("2.3.10.1")]