Integration 2.1g5 :
- aggiunta gestione collegamento a DB utensili e lavorazioni di EgtCAM5 - modifiche varie per variazioni in TechnoEssetre7.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
@@ -17,22 +18,25 @@ namespace ib.essetre.integration.egaltech
|
||||
{
|
||||
public class Generator : ib.essetre.integration.IGenerator
|
||||
{
|
||||
public System.Threading.Thread _thread ;
|
||||
public static DataSet ds = new DataSet() ;
|
||||
public static string SqlConnectionStr = "" ;
|
||||
private System.Threading.Thread _thread ;
|
||||
private static DataSet _ds = new DataSet() ;
|
||||
private static string _SqlConnectionStr = "" ;
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
public Generator()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
public void Run(InOutParameters parameters, ICallBack callback)
|
||||
{
|
||||
_thread = new Thread(() => DoJob( parameters, callback)) ;
|
||||
_thread.Start() ;
|
||||
_thread.Start() ;
|
||||
}
|
||||
|
||||
private delegate void dDoJob( InOutParameters parameters, ICallBack callback) ;
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
// campo data ultima modifica nel DATABASE [lastModified]
|
||||
private static void DoJob( InOutParameters parameters, ICallBack callback)
|
||||
{
|
||||
@@ -42,14 +46,10 @@ namespace ib.essetre.integration.egaltech
|
||||
|
||||
//GetMachineParams(parameters);
|
||||
|
||||
SqlConnectionStr = parameters.ConnectionString ;
|
||||
_SqlConnectionStr = parameters.ConnectionString ;
|
||||
|
||||
String ExePath = parameters.Read( "EGALTECH", "PATH_EXE", "") ;
|
||||
String BtlDir = parameters.Read( "EGALTECH", "DIR_BTL", "") ;
|
||||
// Se la directory in cui salvare il file non esiste viene creata
|
||||
DirectoryInfo di = new DirectoryInfo( BtlDir) ;
|
||||
if ( ! di.Exists)
|
||||
di.Create() ;
|
||||
String ExePath = GetExePath( parameters) ;
|
||||
String BtlDir = GetBtlDir( parameters) ;
|
||||
|
||||
int numBars = parameters.Patterns.Length ;
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace ib.essetre.integration.egaltech
|
||||
}
|
||||
|
||||
// Connessione al DB ed esecuzione query
|
||||
using ( SqlConnection cn = new SqlConnection( SqlConnectionStr)) {
|
||||
using ( SqlConnection cn = new SqlConnection( _SqlConnectionStr)) {
|
||||
cn.Open() ;
|
||||
using (SqlCommand cmd = new SqlCommand( sql, cn)) {
|
||||
cmd.Parameters.Add( "@firstId", SqlDbType.Int) ;
|
||||
@@ -108,8 +108,8 @@ namespace ib.essetre.integration.egaltech
|
||||
var dataAdapter = new SqlDataAdapter( cmd) ;
|
||||
|
||||
// Lettura DB e riempimento DataSet
|
||||
ds.Clear() ;
|
||||
dataAdapter.Fill( ds) ;
|
||||
_ds.Clear() ;
|
||||
dataAdapter.Fill( _ds) ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,8 +141,11 @@ namespace ib.essetre.integration.egaltech
|
||||
// Se scrittura Btl riuscita, lancio EgtCAM5
|
||||
if ( BtlOk) {
|
||||
// Esecuzione di EgtCAM5 con parametri path BTL, nome macchina e modo
|
||||
string path = "\"" + BtlPath + "\" " + parameters.MachineName + " " + (int)parameters.UIMode ;
|
||||
Process process = Process.Start( ExePath, path) ;
|
||||
Process process = new Process() ;
|
||||
process.StartInfo.FileName = ExePath ;
|
||||
process.StartInfo.Arguments = "\"" + BtlPath + "\" " + parameters.MachineName + " " + (int)parameters.UIMode ;
|
||||
process.StartInfo.UseShellExecute = false ;
|
||||
process.Start() ;
|
||||
// Attendo il termine del processo
|
||||
while ( ! process.HasExited) {
|
||||
process.Refresh() ;
|
||||
@@ -261,6 +264,7 @@ namespace ib.essetre.integration.egaltech
|
||||
callback.Done( parameters) ; //fine
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
private static int? GetVal( string sText, string sKey)
|
||||
{
|
||||
string[] sParts = sText.Split( new Char[] { '=' }) ;
|
||||
@@ -272,15 +276,17 @@ namespace ib.essetre.integration.egaltech
|
||||
return nVal ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
public void Abort()
|
||||
{
|
||||
//non implementata al momento
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
// Il seguente metodo prende i record visualizzati in ds (Caso: Produzione) e li carica in un oggetto BTL
|
||||
public static void GetListaTasks( BTL btlObject)
|
||||
{
|
||||
DataTable dTab = ds.Tables[0] ;
|
||||
DataTable dTab = _ds.Tables[0] ;
|
||||
Int32 listaTasksCount = dTab.Rows.Count ;
|
||||
if ( listaTasksCount == 0)
|
||||
return ;
|
||||
@@ -386,10 +392,11 @@ namespace ib.essetre.integration.egaltech
|
||||
btlObject.parts.Sort( (p, q) => p.x.CompareTo( q.x)) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
// Il seguente metodo prende i record visualizzati in ds (Caso: Ordine) e li carica in un oggetto BTL
|
||||
public static void GetListaProcesses( BTL btlObject)
|
||||
{
|
||||
DataTable dTab = ds.Tables[0] ;
|
||||
DataTable dTab = _ds.Tables[0] ;
|
||||
int listaProcessesCount = dTab.Rows.Count ;
|
||||
if ( listaProcessesCount == 0) {
|
||||
btlObject.parts = null ;
|
||||
@@ -498,13 +505,14 @@ namespace ib.essetre.integration.egaltech
|
||||
btlObject.parts.Sort( (p, q) => p.x.CompareTo( q.x)) ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
// Il seguente metodo si connette al DB per estrarre tramite una query i cutId della tabella vw_Cut
|
||||
// aventi patternId e ProductionId che corrispondono a quelli passati come argomento
|
||||
private static List<int> GetListaCutIdP()
|
||||
{
|
||||
List<int> ListaCutId = new List<int>() ;
|
||||
|
||||
DataTable dTab = ds.Tables[0] ;
|
||||
DataTable dTab = _ds.Tables[0] ;
|
||||
int listaTasksCount = dTab.Rows.Count ;
|
||||
for ( int f = 0 ; f < listaTasksCount ; f++) {
|
||||
int nCut = (int) dTab.Rows[f]["cutId"] ;
|
||||
@@ -515,6 +523,7 @@ namespace ib.essetre.integration.egaltech
|
||||
return ListaCutId ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
// Recupera la lunghezza della barra nel caso Produzione (colonna "l")
|
||||
private static double GetBarLengthP( int patternId, int productionId)
|
||||
{
|
||||
@@ -526,7 +535,7 @@ namespace ib.essetre.integration.egaltech
|
||||
"AND productionId = @secondId" ;
|
||||
|
||||
// Connessione al DB ed esecuzione query
|
||||
using ( SqlConnection cn = new SqlConnection( SqlConnectionStr)) {
|
||||
using ( SqlConnection cn = new SqlConnection( _SqlConnectionStr)) {
|
||||
cn.Open() ;
|
||||
using ( SqlCommand sqlCommand = new SqlCommand( sqlBarLength, cn)) {
|
||||
sqlCommand.Parameters.Add( "@firstId", SqlDbType.Int) ;
|
||||
@@ -543,13 +552,14 @@ namespace ib.essetre.integration.egaltech
|
||||
return barLength ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
// Recupera la lunghezza della barra nel caso Ordine (colonna "length", ovvero la lunghezza della singola trave)
|
||||
// a cui aggiungiamo un valore fisso (es. 2000)
|
||||
private static double GetBarLengthO( int elementId, int projectId)
|
||||
{
|
||||
double barLength = 0 ;
|
||||
|
||||
DataTable dTab = ds.Tables[0] ;
|
||||
DataTable dTab = _ds.Tables[0] ;
|
||||
int listaProcessesCount = dTab.Rows.Count ;
|
||||
if ( listaProcessesCount > 0) {
|
||||
double beamLength = Convert.ToDouble( dTab.Rows[0]["length"]) ;
|
||||
@@ -562,6 +572,68 @@ namespace ib.essetre.integration.egaltech
|
||||
return barLength ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
// Restituisce la path di esecuzione di EgtCam5
|
||||
private static String GetExePath( InOutParameters parameters)
|
||||
{
|
||||
return parameters.Read( "EGALTECH", "PATH_EXE", "") ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
// Restituisce il direttorio per i file BTL
|
||||
private static String GetBtlDir( InOutParameters parameters)
|
||||
{
|
||||
String BtlDir = parameters.Read( "EGALTECH", "DIR_BTL", "") ;
|
||||
// Se la directory non esiste viene creata
|
||||
DirectoryInfo di = new DirectoryInfo( BtlDir) ;
|
||||
if ( ! di.Exists)
|
||||
di.Create() ;
|
||||
return BtlDir ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
// Visualizzazione finestra gestione DB utensili
|
||||
public bool ShowTools( InOutParameters parameters)
|
||||
{
|
||||
string ExePath = GetExePath( parameters) ;
|
||||
string BtlDir = GetBtlDir( parameters) ;
|
||||
string BtlPath = Path.Combine( BtlDir, "QQQ.btl") ;
|
||||
// Esecuzione di EgtCAM5 con parametri path BTL, nome macchina e modo
|
||||
Process process = new Process() ;
|
||||
process.StartInfo.FileName = ExePath ;
|
||||
process.StartInfo.Arguments = "\"" + BtlPath + "\" " + parameters.MachineName + " 11" ;
|
||||
process.StartInfo.UseShellExecute = false ;
|
||||
process.Start() ;
|
||||
// Attendo il termine del processo
|
||||
while ( ! process.HasExited) {
|
||||
process.Refresh() ;
|
||||
System.Threading.Thread.Sleep( 50) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
// Visualizzazione finestra gestione DB lavorazioni
|
||||
public bool ShowJobs( InOutParameters parameters)
|
||||
{
|
||||
// Recupero dati
|
||||
string ExePath = GetExePath( parameters) ;
|
||||
string BtlDir = GetBtlDir( parameters) ;
|
||||
string BtlPath = Path.Combine( BtlDir, "QQQ.btl") ;
|
||||
// Esecuzione di EgtCAM5 con parametri path BTL, nome macchina e modo
|
||||
Process process = new Process() ;
|
||||
process.StartInfo.FileName = "C:\\EgtProg\\EgtCAM5\\EgtCam5R32.exe" ;
|
||||
process.StartInfo.Arguments = "\"" + BtlPath + "\" " + parameters.MachineName + " 12" ;
|
||||
process.StartInfo.UseShellExecute = false ;
|
||||
process.Start() ;
|
||||
// Attendo il termine del processo
|
||||
while ( ! process.HasExited) {
|
||||
process.Refresh() ;
|
||||
System.Threading.Thread.Sleep( 50) ;
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
// Dati utensili e macchina
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
@@ -569,6 +641,7 @@ namespace ib.essetre.integration.egaltech
|
||||
[DllImport("kernel32", CharSet = CharSet.Unicode)]
|
||||
static extern long WritePrivateProfileString( string Section, string Key, string Value, string FilePath) ;
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
// Scrive il file ToolConfig.ini che include gli utensili e i relativi parametri presi dal DB
|
||||
private static void GetToolParams( InOutParameters parameters)
|
||||
{
|
||||
@@ -584,7 +657,7 @@ namespace ib.essetre.integration.egaltech
|
||||
File.Delete( IniPath) ;
|
||||
|
||||
// Preparazione interrogazione del DB
|
||||
SqlConnectionStr = parameters.ConnectionString ;
|
||||
_SqlConnectionStr = parameters.ConnectionString ;
|
||||
DataSet dsTools = new DataSet() ;
|
||||
string sqlTool = "SELECT [vw_Tool].[toolId], [code], [jobType], [toolType], " +
|
||||
"[enabled], [note], [position], [file3ds], [rpm], [feed], [srot], " +
|
||||
@@ -595,7 +668,7 @@ namespace ib.essetre.integration.egaltech
|
||||
"ON [vw_Tool].[toolId] = [vw_ToolParam].[toolId] ";
|
||||
|
||||
// Connessione al DB ed esecuzione query
|
||||
using ( SqlConnection cn = new SqlConnection( SqlConnectionStr)) {
|
||||
using ( SqlConnection cn = new SqlConnection( _SqlConnectionStr)) {
|
||||
cn.Open() ;
|
||||
using ( SqlCommand cmd = new SqlCommand( sqlTool, cn)) {
|
||||
var dataAdapter = new SqlDataAdapter( cmd) ;
|
||||
@@ -640,7 +713,8 @@ namespace ib.essetre.integration.egaltech
|
||||
|
||||
}
|
||||
|
||||
// Scrive il file MachConfig_[MachineName].ini che include i parametri macchina presi dal DB
|
||||
//-------------------------------------------------------------------------------------------------------------
|
||||
// Scrive il file MachConfig_[MachineName].ini che include i parametri macchina presi dal DB
|
||||
private static void GetMachineParams( InOutParameters parameters)
|
||||
{
|
||||
// Direttorio di scrittura del file e sua creazione se non esiste
|
||||
@@ -656,7 +730,7 @@ namespace ib.essetre.integration.egaltech
|
||||
File.Delete( IniPath) ;
|
||||
|
||||
// Preparazione interrogazione del DB
|
||||
SqlConnectionStr = parameters.ConnectionString ;
|
||||
_SqlConnectionStr = parameters.ConnectionString ;
|
||||
DataSet dsMachs = new DataSet() ;
|
||||
|
||||
string sqlMach = "SELECT [group], [key], [value] " +
|
||||
@@ -665,7 +739,7 @@ namespace ib.essetre.integration.egaltech
|
||||
"OR [group] = 'TRAVE' ";
|
||||
|
||||
// Connessione al DB ed esecuzione query
|
||||
using ( SqlConnection cn = new SqlConnection(SqlConnectionStr)) {
|
||||
using ( SqlConnection cn = new SqlConnection(_SqlConnectionStr)) {
|
||||
cn.Open() ;
|
||||
using ( SqlCommand cmd = new SqlCommand(sqlMach, cn)) {
|
||||
var dataAdapter = new SqlDataAdapter( cmd) ;
|
||||
|
||||
@@ -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.7.4")]
|
||||
[assembly: AssemblyFileVersion("2.1.7.4")]
|
||||
[assembly: AssemblyVersion("2.1.7.5")]
|
||||
[assembly: AssemblyFileVersion("2.1.7.5")]
|
||||
|
||||
Reference in New Issue
Block a user