1212 lines
52 KiB
VB.net
1212 lines
52 KiB
VB.net
Imports System
|
|
Imports System.Windows.Forms
|
|
Imports System.Collections.Generic
|
|
Imports System.Data
|
|
Imports System.Data.SqlClient
|
|
Imports System.Diagnostics
|
|
Imports System.IO
|
|
Imports System.Linq
|
|
Imports System.Runtime.InteropServices
|
|
Imports System.Text
|
|
Imports System.Threading
|
|
Imports System.Threading.Tasks
|
|
Imports System.Globalization
|
|
Imports EgtUILib
|
|
Imports EgtWPFLib5
|
|
|
|
Public Class CalcIntegration
|
|
|
|
Private _thread As System.Threading.Thread
|
|
Private Shared _ds As DataSet = New DataSet()
|
|
Private Shared _SqlConnectionStr As String = ""
|
|
|
|
Public Enum CmdType As Integer
|
|
GENERATE = 0
|
|
MODIFY = 1
|
|
SIMULATE = 2
|
|
CHECK = 3
|
|
CHECKGEN = 4
|
|
POINT_CLOUD = 5
|
|
RAWPART = 6
|
|
End Enum
|
|
|
|
Public Class Bar
|
|
'Public piInfo As PatternInfo
|
|
Public nBarState As Integer
|
|
Public nBarId As Integer
|
|
Public sBarPath As String
|
|
Public bBarOk As Boolean
|
|
Public nCmdType As Integer
|
|
Public nBarType As ProjectType
|
|
End Class
|
|
|
|
Private Structure MyProc
|
|
Public bEnable As Boolean
|
|
Public Proc As Process
|
|
Public nBar As Integer
|
|
End Structure
|
|
|
|
Public Sub New()
|
|
End Sub
|
|
|
|
Public Sub Run(vBar As Bar(), sProjDirPath As String, callback As Action(Of Double, String, Boolean)) 'ByVal parameters As InOutParameters, ByVal callback As ICallBack)
|
|
_thread = New Thread(Sub()
|
|
DoJob(vBar, sProjDirPath, callback)
|
|
End Sub) ',parameters, callback))
|
|
_thread.Start()
|
|
End Sub
|
|
|
|
'Private Delegate Sub dDoJob(ByVal parameters As InOutParameters, ByVal callback As ICallBack)
|
|
|
|
Private Shared Function CreateNewProjectFromPart(nPartId As Integer, sProjDirPath As String) As String
|
|
' assegno Id a CutId per calcoli
|
|
EgtSetInfo(nPartId, "CUTID", nPartId)
|
|
' assegno TASKID alla feature per calcoli
|
|
Dim nProcessingId As Integer = EgtGetFirstNameInGroup(nPartId, PROCESSINGS)
|
|
Dim nFeatureId As Integer = EgtGetFirstInGroup(nProcessingId)
|
|
While nFeatureId <> GDB_ID.NULL
|
|
' verifico che sia una feature
|
|
Dim nGRP As Integer
|
|
If EgtGetInfo(nFeatureId, BTL_FTR_GRP, nGRP) Then
|
|
' assegno TASKID alla feature per calcoli
|
|
EgtSetInfo(nFeatureId, "TASKID", nFeatureId)
|
|
End If
|
|
nFeatureId = EgtGetNext(nFeatureId)
|
|
End While
|
|
|
|
' recupero visibilita' pezzo e lo imposto a visibile
|
|
Dim nPartMode As Integer
|
|
EgtGetMode(nPartId, nPartMode)
|
|
EgtSetMode(nPartId, GDB_MD.STD)
|
|
|
|
' salvo pezzo nel suo progetto
|
|
Dim bOk As Boolean = False
|
|
Dim nPDN As Integer = 0
|
|
EgtGetInfo(nPartId, BTL_PRT_PDN, nPDN)
|
|
Dim sPartFilePath As String = sProjDirPath & "/" & nPDN & ".bwe"
|
|
bOk = EgtSaveObjToFile(nPartId, sPartFilePath, NGE.BIN)
|
|
|
|
'ripristino visibilita' pezzo
|
|
EgtSetMode(nPartId, nPartMode)
|
|
Return If(bOk, sPartFilePath, String.Empty)
|
|
End Function
|
|
|
|
Private Shared Function CreateNewProjectFromMachGroup(nMachGroupId As Integer, sProjDirPath As String) As String
|
|
Dim sMachGroupFilePath As String = sProjDirPath & "\" & nMachGroupId & ".bwe"
|
|
' salvo gruppo di lavorazione nel suo progetto
|
|
If EgtSaveObjToFile(nMachGroupId, sMachGroupFilePath, NGE.BIN) Then
|
|
Return sMachGroupFilePath
|
|
End If
|
|
Return String.Empty
|
|
End Function
|
|
|
|
Private Shared Sub DoJob(vBar As Bar(), sProjDirPath As String, callback As Action(Of Double, String, Boolean)) ', parameters As InOutParameters, callback As ICallBack)
|
|
Dim bCancel As Boolean = False
|
|
callback(0, "Init", bCancel)
|
|
|
|
' creo progetti a seconda del tipo
|
|
For Each Bar In vBar
|
|
If Bar.nBarType = ProjectType.PROJ Then
|
|
Bar.sBarPath = CreateNewProjectFromPart(Bar.nBarId, sProjDirPath)
|
|
ElseIf Bar.nBarType = ProjectType.PROD Then
|
|
Bar.sBarPath = CreateNewProjectFromMachGroup(Bar.nBarId, sProjDirPath)
|
|
End If
|
|
Next
|
|
|
|
callback(0.1, "", bCancel)
|
|
|
|
'_SqlConnectionStr = parameters.ConnectionString
|
|
Dim ExePath As String = String.Empty
|
|
GetMainPrivateProfileString(S_BEAM, K_CALCPATH, "", ExePath)
|
|
'Dim DataDir As String = GetDataDir(parameters)
|
|
' Numero di barre
|
|
Dim numBars As Integer = vBar.Count
|
|
If numBars = 0 Then Return
|
|
'' Se modalità Cloud, allora conta solo la prima barra
|
|
'Dim bCloud As Boolean = (parameters.UIMode = InOutParameters.UIModes.CLOUD)
|
|
'If bCloud Then numBars = 1
|
|
|
|
' Numero di core logici da utilizzare (minimo tra presenti sul PC e imposti da INI)
|
|
Dim nMaxThread As Integer = Math.Min(Environment.ProcessorCount, Map.refMainWindowVM.MainWindowM.GetMaxInstances())
|
|
|
|
' Frazione di avanzamento del lavoro (in pu)
|
|
Dim dProgress As Double = 0
|
|
'' Genero i Btl di tutte le barre
|
|
'Dim vBar As Bar() = New Bar(numBars + nMaxThread - 1) {}
|
|
|
|
'For i As Integer = 0 To numBars - 1
|
|
' Dim pattInfo As PatternInfo = parameters.Patterns(i)
|
|
' Dim btlObject As BTL = New BTL()
|
|
' ' Se il parametro IsFromProject è TRUE viene eseguita la query sulle tabelle Project,
|
|
' ' se invece è FALSE viene eseguita la query sulle tabelle Production
|
|
|
|
' Dim sql As String = ""
|
|
|
|
' If pattInfo.IsFromProject Then
|
|
' sql = "SELECT E.projectId, " & "E.elementId, 0 cutId, processId, info1, info2, enabled, level, " & "inTools, outTools, isChecked, P.done, isoType, ax, ay, az, P.x, P.y, P.z, " & "P.flagDeleted, P.[group], [key], face, edge, des, " & "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, " & "E.inverted, E.rotated, 0 doneTime, 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 " & "ON P.projectId=E.projectId AND P.elementId=E.elementId " & "WHERE E.projectId = @firstId AND E.elementId = @secondId"
|
|
' Else
|
|
' sql = "SELECT vw_Cut.productionId, " & "vw_Cut.patternId, vw_Cut.cutId, taskId, info1, info2, enabled, level, " & "inTools, outTools, isChecked, vw_Task.done, isoType, ax, ay, az, vw_Cut.x, vw_Cut.y, vw_Cut.z, " & "vw_Task.flagDeleted, [group], [key], face, edge, des, " & "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, " & "inverted, rotated, doneTime, startAngle, endAngle, referenceCutId, length, width, height " & "FROM dbo.vw_Task " & "RIGHT OUTER JOIN dbo.vw_Cut " & "ON (vw_Task.cutId = vw_Cut.cutId AND vw_Task.patternId = vw_Cut.patternId AND vw_Task.productionId = vw_Cut.productionId) " & "WHERE vw_Cut.productionId = @firstId AND vw_Cut.patternId = @secondId"
|
|
' End If
|
|
|
|
' ' Connessione al DB ed esecuzione query
|
|
' Using cn As SqlConnection = New SqlConnection(_SqlConnectionStr)
|
|
' cn.Open()
|
|
|
|
' Using cmd As SqlCommand = New SqlCommand(sql, cn)
|
|
' cmd.Parameters.Add("@firstId", SqlDbType.Int)
|
|
' cmd.Parameters.Add("@secondId", SqlDbType.Int)
|
|
|
|
' If pattInfo.IsFromProject Then
|
|
' cmd.Parameters("@firstId").Value = pattInfo.ProjectId
|
|
' cmd.Parameters("@secondId").Value = pattInfo.ElementId
|
|
' Else
|
|
' cmd.Parameters("@firstId").Value = pattInfo.ProductionId
|
|
' cmd.Parameters("@secondId").Value = pattInfo.PatternId
|
|
' End If
|
|
|
|
' Dim dataAdapter = New SqlDataAdapter(cmd)
|
|
' ' Lettura DB e riempimento DataSet
|
|
' _ds.Clear()
|
|
' dataAdapter.Fill(_ds)
|
|
' End Using
|
|
' End Using
|
|
|
|
' ' Verifica parametro isFromProject nel caso Ordine viene ottenuta la lista dei Process,
|
|
' ' nel caso Produzione viene ottenuta la lista dei Task
|
|
' If pattInfo.IsFromProject Then
|
|
' GetListaProcesses(btlObject)
|
|
' Else
|
|
' GetListaTasks(btlObject)
|
|
' End If
|
|
|
|
' ' Recupero lo stato della barra
|
|
' Dim nBarState As Integer = 0
|
|
' If Not pattInfo.IsFromProject Then nBarState = GetBarStateP(btlObject.patternId, btlObject.productionId)
|
|
' ' Dialog con Progress Bar
|
|
' dProgress += 0.1 / numBars
|
|
' Dim sProg As String = (dProgress * 100).ToString("F1", CultureInfo.InvariantCulture)
|
|
' callback.Progress(CSng(dProgress), " Progress: " & sProg & "%" & vbLf, bCancel)
|
|
|
|
' If bCancel Then
|
|
' callback.Done(parameters)
|
|
' Return
|
|
' End If
|
|
|
|
' ' Scrittura del file BTL
|
|
' ' Path completa del nome del file da salvare
|
|
' Dim BtlPath As String = GetBtlPath(DataDir, pattInfo)
|
|
' Dim BtlOk As Boolean = btlObject.WriteIntoFile(BtlPath, pattInfo.IsFromProject)
|
|
' ' Se modalità cloud, scrittura del file di punti
|
|
' Dim bErrOnCloud As Boolean = False
|
|
|
|
' If bCloud Then
|
|
|
|
' If pattInfo.Cloud IsNot Nothing Then
|
|
|
|
' Using tw = New StreamWriter(Path.ChangeExtension(BtlPath, ".pnt"), False)
|
|
|
|
' For j As Integer = 0 To pattInfo.Cloud.Count() - 1
|
|
' Dim dPosX As Double = -pattInfo.Cloud(j).Y
|
|
' Dim dPosY As Double = pattInfo.Cloud(j).X
|
|
' Dim sPosX As String = dPosX.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)
|
|
' Dim sPosY As String = dPosY.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)
|
|
' tw.WriteLine(sPosX & " " & sPosY)
|
|
' Next
|
|
' End Using
|
|
' Else
|
|
' BtlOk = False
|
|
' bErrOnCloud = True
|
|
' End If
|
|
' End If
|
|
' ' Se scrittura Btl non riuscita
|
|
' If Not BtlOk Then
|
|
' ' scrivo direttamente il file di errore
|
|
' Dim ErrCutId As Integer = (If(pattInfo.IsFromProject, pattInfo.ElementId, pattInfo.PatternId))
|
|
|
|
' Using tw = New StreamWriter(Path.ChangeExtension(BtlPath, ".txt"), False)
|
|
' tw.WriteLine("ERR=10")
|
|
' tw.WriteLine(If(bErrOnCloud, "Cloud without points", "BTL without processes"))
|
|
' tw.WriteLine("CUTID=" & ErrCutId.ToString())
|
|
' tw.WriteLine("TASKID=0")
|
|
' End Using
|
|
' ' elimino eventuale file Cn già presente
|
|
' If parameters.UIMode = InOutParameters.UIModes.HIDDEN Then
|
|
' Dim CncPath As String = Path.ChangeExtension(BtlPath, ".cnc")
|
|
' If File.Exists(CncPath) Then File.Delete(CncPath)
|
|
' End If
|
|
' ' altrimenti
|
|
' Else
|
|
' ' cancello eventuale file di errore già presente
|
|
' Dim TxtPath As String = Path.ChangeExtension(BtlPath, ".txt")
|
|
' If File.Exists(TxtPath) Then File.Delete(TxtPath)
|
|
' End If
|
|
' ' Salvo dati
|
|
' vBar(i).piInfo = pattInfo
|
|
' vBar(i).nBarState = nBarState
|
|
' vBar(i).sBtlPath = BtlPath
|
|
' vBar(i).bBtlOk = BtlOk
|
|
'Next
|
|
|
|
' Lancio in parallelo più processi (senza superare il numero di core logici presenti)
|
|
Dim vProc As MyProc() = New MyProc(nMaxThread - 1) {}
|
|
For j As Integer = 0 To nMaxThread - 1
|
|
vProc(j).nBar = -1
|
|
vProc(j).bEnable = True
|
|
Next
|
|
|
|
' Processo i Btl in parallelo
|
|
Dim nCurrBar As Integer = 0
|
|
Dim nDoneBar As Integer = 0
|
|
Dim nShiftBar As Integer = 0
|
|
Dim nActProc As Integer = 0
|
|
|
|
While nCurrBar < numBars + nShiftBar OrElse nActProc > 0
|
|
|
|
For j As Integer = 0 To nMaxThread - 1
|
|
If Not vProc(j).bEnable Then Continue For
|
|
Dim bDone As Boolean = False
|
|
|
|
If vProc(j).nBar = -1 Then
|
|
|
|
If nCurrBar < numBars + nShiftBar Then
|
|
|
|
If vBar(nCurrBar).bBarOk Then
|
|
vProc(j).Proc = New Process()
|
|
vProc(j).Proc.StartInfo.FileName = ExePath
|
|
'Dim nMode As Integer = CInt(parameters.UIMode)
|
|
'If parameters.UIMode = InOutParameters.UIModes.HIDDEN AndAlso vBar(nCurrBar).nBarState <> 0 Then nMode = 4
|
|
vProc(j).Proc.StartInfo.Arguments = """" & vBar(nCurrBar).sBarPath & """ " & """" & Map.refMachinePanelVM.SelectedMachine.nType & """ " &
|
|
"""" & Map.refMachinePanelVM.SelectedMachine.Name & """ " & vBar(nCurrBar).nCmdType
|
|
vProc(j).Proc.StartInfo.UseShellExecute = False
|
|
|
|
If vProc(j).Proc.Start() Then
|
|
vProc(j).nBar = nCurrBar
|
|
nCurrBar += 1
|
|
nActProc += 1
|
|
End If
|
|
Else
|
|
ProcessResults(vBar(nCurrBar)) ', vBar(nCurrBar).piInfo, parameters.UIMode)
|
|
bDone = True
|
|
nCurrBar += 1
|
|
End If
|
|
End If
|
|
Else
|
|
|
|
If vProc(j).Proc.HasExited Then
|
|
' se terminato con successo
|
|
If vProc(j).Proc.ExitCode = 0 Then
|
|
' salvo il risultato
|
|
ProcessResults(vBar(vProc(j).nBar)) ', vBar(vProc(j).nBar).piInfo, parameters.UIMode)
|
|
bDone = True
|
|
vProc(j).nBar = -1
|
|
nActProc -= 1
|
|
' se superato il numero di processi eseguibili in parallelo
|
|
ElseIf vProc(j).Proc.ExitCode = 1 Then
|
|
' aggiungo il pezzo in coda
|
|
If numBars + nShiftBar < numBars + nMaxThread Then
|
|
vBar(numBars + nShiftBar) = vBar(vProc(j).nBar)
|
|
nShiftBar += 1
|
|
End If
|
|
' disabilito il processo
|
|
vProc(j).bEnable = False
|
|
vProc(j).nBar = -1
|
|
nActProc -= 1
|
|
' altrimenti (errore generico di esecuzione)
|
|
Else
|
|
' salvo il risultato
|
|
ProcessResults(vBar(vProc(j).nBar)) ', parameters.UIMode)
|
|
bDone = True
|
|
vProc(j).nBar = -1
|
|
nActProc -= 1
|
|
End If
|
|
Else
|
|
vProc(j).Proc.Refresh()
|
|
End If
|
|
End If
|
|
|
|
If bDone Then
|
|
' Dialog con Progress Bar
|
|
dProgress += (0.9 / numBars)
|
|
nDoneBar += 1
|
|
Dim sProg As String = (dProgress * 100).ToString("F1", CultureInfo.InvariantCulture)
|
|
callback(dProgress, " Progress: " & sProg & "% Count: " & nDoneBar & " / " & numBars, bCancel)
|
|
|
|
If bCancel Then
|
|
' fine
|
|
callback(1, "", bCancel)
|
|
Return
|
|
End If
|
|
End If
|
|
|
|
Thread.Sleep(1)
|
|
Next
|
|
|
|
' Verifico che i processi non siano andati tutti in errore
|
|
Dim bAllKO As Boolean = True
|
|
|
|
For j As Integer = 0 To nMaxThread - 1
|
|
If vProc(j).bEnable Then bAllKO = False
|
|
Next
|
|
|
|
If bAllKO Then
|
|
MessageBox.Show("Execution error (all processes are disabled)")
|
|
Exit While
|
|
End If
|
|
|
|
Thread.Sleep(10)
|
|
End While
|
|
|
|
'callback.Progress(1, "End", bCancel)
|
|
Thread.Sleep(300)
|
|
' fine
|
|
callback(1, "Done", bCancel)
|
|
End Sub
|
|
|
|
'Public Sub Abort()
|
|
'End Sub
|
|
|
|
Private Shared Sub ProcessResults(ByVal Bar As Bar) ' , ByVal pattInfo As PatternInfo, ByVal UIMode As InOutParameters.UIModes)
|
|
'If UIMode = InOutParameters.UIModes.SHOWUI OrElse UIMode = InOutParameters.UIModes.SIMULAZIONE Then Return
|
|
Dim BtlPath As String = Bar.sBarPath
|
|
Dim bErrors As Boolean = False
|
|
Dim nLastErr As Integer = 0
|
|
Dim sLastMsg As String = ""
|
|
Dim nCurrCutId As Integer = 0
|
|
'Dim dctErr As Dictionary(Of Integer, PatternInfo.Results) = New Dictionary(Of Integer, PatternInfo.Results)()
|
|
'Dim dctRot As Dictionary(Of Integer, Double) = New Dictionary(Of Integer, Double)()
|
|
Dim nTotTime As Integer = 0
|
|
'Dim resCurrExe As PatternInfo.Results = Nothing, dCurrRot As Double = Nothing
|
|
|
|
If File.Exists(Path.ChangeExtension(BtlPath, ".txt")) Then
|
|
Dim nErr As Integer = 0
|
|
Dim sMsg As String = ""
|
|
Dim dRot As Double = 0
|
|
Dim cutId As Integer = 0
|
|
Dim prevCutId As Integer = GDB_ID.NULL
|
|
Dim currBTLPart As BTLPart
|
|
Dim taskId As Integer = 0
|
|
Dim lines As String() = System.IO.File.ReadAllLines(Path.ChangeExtension(BtlPath, ".txt"))
|
|
|
|
For Each line As String In lines
|
|
|
|
If line.StartsWith("ERR=") Then
|
|
Dim nVal As Integer? = GetVal(line, "ERR")
|
|
nErr = (If(nVal IsNot Nothing, nVal.Value, 0))
|
|
sMsg = ""
|
|
cutId = 0
|
|
taskId = 0
|
|
ElseIf line.StartsWith("ROT=") Then
|
|
Dim nVal As Integer? = GetVal(line, "ROT")
|
|
Dim nRot As Integer = (If(nVal IsNot Nothing, nVal.Value, 0))
|
|
dRot = ((4 - nRot) Mod 4) * 90
|
|
ElseIf line.StartsWith("CUTID=") Then
|
|
Dim nVal As Integer? = GetVal(line, "CUTID")
|
|
cutId = (If(nVal IsNot Nothing, nVal.Value, 0))
|
|
If cutId <> prevCutId Then
|
|
' aggiornamento globale pezzo precedente
|
|
If cutId <> GDB_ID.NULL AndAlso cutId <> 0 Then
|
|
'currBTLPart.CalcGlobalUpdate()
|
|
End If
|
|
' aggiornamento risultati in struttura BTL
|
|
If Bar.nBarType = ProjectType.PROJ Then
|
|
' cerco pezzo in btl structure da id
|
|
For Each Part In Map.refProjectVM.BTLStructure.PartList
|
|
If Part.nPartId = cutId Then
|
|
currBTLPart = Part
|
|
End If
|
|
Next
|
|
End If
|
|
End If
|
|
prevCutId = cutId
|
|
|
|
'If cutId <> nCurrCutId Then
|
|
' nCurrCutId = cutId
|
|
' dctErr.Clear()
|
|
' dctRot.Clear()
|
|
'End If
|
|
ElseIf line.StartsWith("TASKID=") Then
|
|
Dim nVal As Integer? = GetVal(line, "TASKID")
|
|
taskId = (If(nVal IsNot Nothing, nVal.Value, 0))
|
|
'Dim resExe As PatternInfo.Results = PatternInfo.Results.OK
|
|
|
|
'If nErr = 22 Then
|
|
' resExe = PatternInfo.Results.COLLISION
|
|
' bErrors = True
|
|
|
|
' If cutId = 0 OrElse taskId = 0 Then
|
|
' nLastErr = nErr
|
|
' sLastMsg = sMsg
|
|
' End If
|
|
'ElseIf nErr > 0 Then
|
|
' resExe = PatternInfo.Results.WARNING
|
|
' bErrors = True
|
|
|
|
' If cutId = 0 OrElse taskId = 0 Then
|
|
' nLastErr = nErr
|
|
' sLastMsg = sMsg
|
|
' End If
|
|
'End If
|
|
|
|
'se taskid diverso da zero, errore feature
|
|
If taskId <> 0 Then
|
|
EgtSetInfo(taskId, ITG_ERR, nErr)
|
|
EgtSetInfo(taskId, ITG_MSG, sMsg)
|
|
EgtSetInfo(taskId, ITG_ROT, dRot)
|
|
' aggiornamento risultati in struttura BTL
|
|
If Bar.nBarType = ProjectType.PROJ Then
|
|
' cerco task in btl structure da id
|
|
If Not IsNothing(currBTLPart) Then
|
|
For Each Feature In currBTLPart.FeatureList
|
|
If Feature.nFeatureId = taskId Then
|
|
Feature.CalcFeatureUpdate(True, nErr, dRot, sMsg)
|
|
End If
|
|
Next
|
|
End If
|
|
End If
|
|
|
|
'se taskid uguale a zero, errore pezzo
|
|
Else
|
|
EgtSetInfo(cutId, ITG_ERR, nErr)
|
|
EgtSetInfo(cutId, ITG_MSG, sMsg)
|
|
EgtSetInfo(cutId, ITG_ROT, dRot)
|
|
' aggiorno in struttura btl
|
|
If Not IsNothing(currBTLPart) Then currBTLPart.CalcPartUpdate(True, nErr, dRot, sMsg)
|
|
|
|
End If
|
|
|
|
|
|
'If taskId <> 0 Then
|
|
|
|
' If dctErr.TryGetValue(taskId, resCurrExe) Then
|
|
|
|
' If resExe > resCurrExe Then
|
|
' dctErr(taskId) = resExe
|
|
' pattInfo.SetTaskState(cutId, taskId, resExe, sMsg)
|
|
' End If
|
|
' Else
|
|
' dctErr(taskId) = resExe
|
|
' pattInfo.SetTaskState(cutId, taskId, resExe, sMsg)
|
|
' End If
|
|
'Else
|
|
' pattInfo.SetTaskState(cutId, taskId, resExe, sMsg)
|
|
'End If
|
|
|
|
'If taskId <> 0 Then
|
|
|
|
' If dctRot.TryGetValue(taskId, dCurrRot) Then
|
|
|
|
' If Math.Abs(dRot) > 1 Then
|
|
' If Math.Abs(dCurrRot) < 1 Then dctRot(taskId) = dRot
|
|
' Else
|
|
' dRot = dCurrRot
|
|
' End If
|
|
' Else
|
|
' dctRot.Add(taskId, dRot)
|
|
' End If
|
|
'End If
|
|
|
|
'If pattInfo.IsFromProject Then
|
|
' pattInfo.SetProcessInfoChosen(cutId, taskId, dRot, 0, False)
|
|
'Else
|
|
' pattInfo.SetTaskInfoChosen(cutId, taskId, dRot, 0, False)
|
|
'End If
|
|
ElseIf line.StartsWith("TIME=") Then
|
|
Dim nVal As Integer? = GetVal(line, "TIME")
|
|
nTotTime = (If(nVal IsNot Nothing, nVal.Value, 0))
|
|
EgtSetInfo(cutId, ITG_TIME, nTotTime)
|
|
ElseIf Not String.IsNullOrWhiteSpace(line) AndAlso line <> "---" Then
|
|
sMsg = line
|
|
End If
|
|
Next
|
|
Else
|
|
bErrors = True
|
|
nLastErr = 25
|
|
sLastMsg = "Execution Error"
|
|
End If
|
|
|
|
' aggiornamento risultati in struttura BTL
|
|
If Bar.nBarType = ProjectType.PROJ Then
|
|
' cerco pezzo in btl structure da id
|
|
For Each Part In Map.refProjectVM.BTLStructure.PartList
|
|
If Part.nPartId = Bar.nBarId Then
|
|
' leggo errori da geometria e li aggiorno in struttura btl
|
|
Part.CalcFeatureUpdate()
|
|
End If
|
|
Next
|
|
|
|
End If
|
|
|
|
'pattInfo.IsDone = True
|
|
|
|
'If Not bErrors Then
|
|
' pattInfo.Result = PatternInfo.Results.OK
|
|
' pattInfo.DetailResult = PatternInfo.DetailResults.MEMORY
|
|
'Else
|
|
|
|
' If nLastErr = 17 Then
|
|
' pattInfo.Result = PatternInfo.Results.[ERROR]
|
|
' pattInfo.DetailResult = PatternInfo.DetailResults.ALL_WARNING
|
|
' pattInfo.Message = sLastMsg
|
|
' ElseIf nLastErr = 19 Then
|
|
' pattInfo.Result = PatternInfo.Results.[ERROR]
|
|
' pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR
|
|
' pattInfo.Message = sLastMsg
|
|
' ElseIf nLastErr = 22 Then
|
|
' pattInfo.Result = PatternInfo.Results.[ERROR]
|
|
' pattInfo.DetailResult = PatternInfo.DetailResults.ALL_COLLISION
|
|
' pattInfo.Message = sLastMsg
|
|
' ElseIf nLastErr = 23 Then
|
|
' pattInfo.Result = PatternInfo.Results.[ERROR]
|
|
' pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR
|
|
' pattInfo.Message = sLastMsg
|
|
' ElseIf nLastErr = 24 Then
|
|
' pattInfo.Result = PatternInfo.Results.[ERROR]
|
|
' pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR
|
|
' pattInfo.Message = sLastMsg
|
|
' ElseIf nLastErr = 25 Then
|
|
' pattInfo.Result = PatternInfo.Results.[ERROR]
|
|
' pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR
|
|
' pattInfo.Message = sLastMsg
|
|
' Else
|
|
' pattInfo.Result = PatternInfo.Results.[ERROR]
|
|
' pattInfo.DetailResult = PatternInfo.DetailResults.MEMORY
|
|
' End If
|
|
'End If
|
|
|
|
'pattInfo.EstimatedTime = nTotTime
|
|
|
|
'If Not bErrors AndAlso (UIMode = InOutParameters.UIModes.HIDDEN OrElse UIMode = InOutParameters.UIModes.CLOUD) Then
|
|
' Dim CncPath As String = Path.ChangeExtension(BtlPath, ".cnc")
|
|
|
|
' If File.Exists(CncPath) Then
|
|
' Dim lines As String = System.IO.File.ReadAllText(CncPath)
|
|
' pattInfo.Iso = lines
|
|
' pattInfo.Result = PatternInfo.Results.OK
|
|
' pattInfo.DetailResult = PatternInfo.DetailResults.ALL_OK
|
|
' Else
|
|
' pattInfo.Iso = ""
|
|
' pattInfo.Result = PatternInfo.Results.[ERROR]
|
|
' pattInfo.DetailResult = PatternInfo.DetailResults.ALL_ERROR
|
|
' End If
|
|
'End If
|
|
End Sub
|
|
|
|
'Public Shared Sub GetListaTasks(ByVal btlObject As BTL)
|
|
' Dim dTab As DataTable = _ds.Tables(0)
|
|
' Dim listaTasksCount As Int32 = dTab.Rows.Count
|
|
' If listaTasksCount = 0 Then Return
|
|
' Dim dRow0 As DataRow = dTab.Rows(0)
|
|
' btlObject.projectNumber = dRow0("projectId").ToString()
|
|
' btlObject.barLength = GetBarLengthP(CInt(dRow0("patternId")), CInt(dRow0("productionId"))).ToString("F3", CultureInfo.InvariantCulture)
|
|
' btlObject.barLoad90 = GetBarLoad90P(CInt(dRow0("patternId")), CInt(dRow0("productionId"))).ToString(CultureInfo.InvariantCulture)
|
|
' btlObject.panelLength = GetBarLengthP(CInt(dRow0("patternId")), CInt(dRow0("productionId"))).ToString("F3", CultureInfo.InvariantCulture)
|
|
' btlObject.panelWidth = GetBarWidthP(CInt(dRow0("patternId")), CInt(dRow0("productionId"))).ToString("F3", CultureInfo.InvariantCulture)
|
|
' btlObject.productionId = CInt(dRow0("productionId"))
|
|
' btlObject.patternId = CInt(dRow0("patternId"))
|
|
' btlObject.parts = New List(Of BTL.Part)()
|
|
' Dim ListaCutParts As List(Of Integer) = GetListaCutIdP()
|
|
|
|
' For c As Integer = 0 To ListaCutParts.Count - 1
|
|
' Dim readPart As BTL.Part = New BTL.Part()
|
|
' Dim bFirst As Boolean = True
|
|
|
|
' For f As Integer = 0 To listaTasksCount - 1
|
|
' Dim dRowF As DataRow = dTab.Rows(f)
|
|
' If CInt(dRowF("cutId")) <> ListaCutParts(c) Then Continue For
|
|
|
|
' If bFirst Then
|
|
' readPart.singleMemberNumber = GetElementSN(CInt(dRowF("elementId")), CInt(dRowF("projectId")))
|
|
' readPart.count = "1"
|
|
' readPart.length = dRowF("length").ToString()
|
|
' readPart.height = dRowF("height").ToString()
|
|
' readPart.width = dRowF("width").ToString()
|
|
' readPart.x = CDbl(dRowF("x"))
|
|
' readPart.z = CDbl(dRowF("z"))
|
|
' readPart.inverted = CDbl(dRowF("inverted"))
|
|
' readPart.rotated = CDbl(dRowF("rotated"))
|
|
' readPart.cutId = CInt(dRowF("cutId"))
|
|
' bFirst = False
|
|
' readPart.features = New List(Of BTL.Feature)()
|
|
' End If
|
|
|
|
' If String.IsNullOrEmpty(dRowF("taskId").ToString()) Then Continue For
|
|
' Dim readFeature As BTL.Feature = New BTL.Feature() With {
|
|
' .taskId = dRowF("taskId").ToString(),
|
|
' .processKey = dRowF("group").ToString() & "-" & dRowF("key").ToString().Substring(1, 3) & "-" & dRowF("face").ToString(),
|
|
' .designation = dRowF("des").ToString(),
|
|
' .processIdent = dRowF("processIdent").ToString(),
|
|
' .sag1 = dRowF("sag1").ToString(),
|
|
' .Text = dRowF("text").ToString(),
|
|
' .Process = If((Convert.ToInt16(dRowF("enabled")) = 1), "YES", "NO"),
|
|
' .processParameters = New List(Of String)(46) From {
|
|
' dRowF("p01").ToString(),
|
|
' dRowF("p02").ToString(),
|
|
' dRowF("p03").ToString(),
|
|
' dRowF("p04").ToString(),
|
|
' dRowF("p05").ToString(),
|
|
' dRowF("p06").ToString(),
|
|
' dRowF("p07").ToString(),
|
|
' dRowF("p08").ToString(),
|
|
' dRowF("p09").ToString(),
|
|
' dRowF("p10").ToString(),
|
|
' dRowF("p11").ToString(),
|
|
' dRowF("p12").ToString(),
|
|
' dRowF("p13").ToString(),
|
|
' dRowF("p14").ToString(),
|
|
' dRowF("p15").ToString(),
|
|
' dRowF("p16").ToString(),
|
|
' dRowF("p17").ToString(),
|
|
' dRowF("p18").ToString(),
|
|
' dRowF("p19").ToString(),
|
|
' dRowF("p20").ToString(),
|
|
' dRowF("p21").ToString(),
|
|
' dRowF("p22").ToString(),
|
|
' dRowF("p23").ToString(),
|
|
' dRowF("p24").ToString(),
|
|
' dRowF("p25").ToString(),
|
|
' dRowF("p26").ToString(),
|
|
' dRowF("q01").ToString(),
|
|
' dRowF("q02").ToString(),
|
|
' dRowF("q03").ToString(),
|
|
' dRowF("q04").ToString(),
|
|
' dRowF("q05").ToString(),
|
|
' dRowF("q06").ToString(),
|
|
' dRowF("q07").ToString(),
|
|
' dRowF("q08").ToString(),
|
|
' dRowF("q09").ToString(),
|
|
' dRowF("q10").ToString(),
|
|
' dRowF("q11").ToString(),
|
|
' dRowF("q12").ToString(),
|
|
' dRowF("q13").ToString(),
|
|
' dRowF("q14").ToString(),
|
|
' dRowF("q15").ToString(),
|
|
' dRowF("q16").ToString(),
|
|
' dRowF("q17").ToString(),
|
|
' dRowF("q18").ToString(),
|
|
' dRowF("q19").ToString(),
|
|
' dRowF("q20").ToString()
|
|
' },
|
|
' .processReference = New List(Of String)(9) From {
|
|
' dRowF("ox").ToString(),
|
|
' dRowF("oy").ToString(),
|
|
' dRowF("oz").ToString(),
|
|
' dRowF("xx").ToString(),
|
|
' dRowF("xy").ToString(),
|
|
' dRowF("xz").ToString(),
|
|
' dRowF("yx").ToString(),
|
|
' dRowF("yy").ToString(),
|
|
' dRowF("yz").ToString()
|
|
' }
|
|
' }
|
|
' readPart.features.Add(readFeature)
|
|
' Next
|
|
|
|
' btlObject.parts.Add(readPart)
|
|
' Next
|
|
|
|
' btlObject.parts.Sort(Function(p, q) p.x.CompareTo(q.x))
|
|
'End Sub
|
|
|
|
Private Shared Function GetVal(ByVal sText As String, ByVal sKey As String) As Integer?
|
|
Dim sParts As String() = sText.Split("="c)
|
|
If String.Compare(sParts(0), sKey) <> 0 Then Return Nothing
|
|
Dim nVal As Integer = Nothing
|
|
|
|
If Not Integer.TryParse(sParts(1), nVal) Then
|
|
Return Nothing
|
|
Else
|
|
Return nVal
|
|
End If
|
|
End Function
|
|
|
|
'Public Shared Sub GetListaProcesses(ByVal btlObject As BTL)
|
|
' Dim dTab As DataTable = _ds.Tables(0)
|
|
' Dim listaProcessesCount As Integer = dTab.Rows.Count
|
|
|
|
' If listaProcessesCount = 0 Then
|
|
' btlObject.parts = Nothing
|
|
' Return
|
|
' End If
|
|
|
|
' Dim dRow0 As DataRow = dTab.Rows(0)
|
|
' btlObject.projectNumber = dRow0("projectId").ToString()
|
|
' btlObject.barLength = GetBarLengthO(CInt(dRow0("elementId")), CInt(dRow0("projectId"))).ToString("F3", CultureInfo.InvariantCulture)
|
|
' btlObject.barLoad90 = "0"
|
|
' btlObject.panelLength = GetPanelLengthO(CInt(dRow0("elementId")), CInt(dRow0("projectId"))).ToString("F3", CultureInfo.InvariantCulture)
|
|
' btlObject.panelWidth = GetPanelWidthO(CInt(dRow0("elementId")), CInt(dRow0("projectId"))).ToString("F3", CultureInfo.InvariantCulture)
|
|
' btlObject.projectId = CInt(dRow0("projectId"))
|
|
' btlObject.elementId = CInt(dRow0("elementId"))
|
|
' btlObject.parts = New List(Of BTL.Part)()
|
|
' Dim ListaCutParts As List(Of Integer) = New List(Of Integer)(1)
|
|
' ListaCutParts.Add(CInt(dRow0("elementId")))
|
|
|
|
' For c As Integer = 0 To ListaCutParts.Count - 1
|
|
' Dim readPart As BTL.Part = New BTL.Part()
|
|
' Dim bFirst As Boolean = True
|
|
|
|
' For f As Integer = 0 To listaProcessesCount - 1
|
|
' Dim dRowF As DataRow = dTab.Rows(f)
|
|
' If CInt(dRowF("elementId")) <> ListaCutParts(c) Then Continue For
|
|
|
|
' If bFirst Then
|
|
' readPart.singleMemberNumber = GetElementSN(CInt(dRow0("elementId")), CInt(dRow0("projectId")))
|
|
' readPart.count = "1"
|
|
' readPart.length = dRowF("length").ToString()
|
|
' readPart.height = dRowF("height").ToString()
|
|
' readPart.width = dRowF("width").ToString()
|
|
' readPart.x = Constants.HeadOverMat
|
|
' readPart.z = Constants.HeadOverMat
|
|
' readPart.inverted = CDbl(dRowF("inverted"))
|
|
' readPart.rotated = CDbl(dRowF("rotated"))
|
|
' readPart.elementId = CInt(dRowF("elementId"))
|
|
' bFirst = False
|
|
' readPart.features = New List(Of BTL.Feature)()
|
|
' End If
|
|
|
|
' If String.IsNullOrEmpty(dRowF("processId").ToString()) Then Continue For
|
|
' Dim readFeature As BTL.Feature = New BTL.Feature() With {
|
|
' .processId = dRowF("processId").ToString(),
|
|
' .processKey = dRowF("group").ToString() & "-" & dRowF("key").ToString().Substring(1, 3) & "-" & dRowF("face").ToString(),
|
|
' .designation = dRowF("des").ToString(),
|
|
' .processIdent = dRowF("processIdent").ToString(),
|
|
' .sag1 = dRowF("sag1").ToString(),
|
|
' .Text = dRowF("text").ToString(),
|
|
' .Process = If((Convert.ToInt16(dRowF("enabled")) = 1), "YES", "NO"),
|
|
' .processParameters = New List(Of String)(46) From {
|
|
' dRowF("p01").ToString(),
|
|
' dRowF("p02").ToString(),
|
|
' dRowF("p03").ToString(),
|
|
' dRowF("p04").ToString(),
|
|
' dRowF("p05").ToString(),
|
|
' dRowF("p06").ToString(),
|
|
' dRowF("p07").ToString(),
|
|
' dRowF("p08").ToString(),
|
|
' dRowF("p09").ToString(),
|
|
' dRowF("p10").ToString(),
|
|
' dRowF("p11").ToString(),
|
|
' dRowF("p12").ToString(),
|
|
' dRowF("p13").ToString(),
|
|
' dRowF("p14").ToString(),
|
|
' dRowF("p15").ToString(),
|
|
' dRowF("p16").ToString(),
|
|
' dRowF("p17").ToString(),
|
|
' dRowF("p18").ToString(),
|
|
' dRowF("p19").ToString(),
|
|
' dRowF("p20").ToString(),
|
|
' dRowF("p21").ToString(),
|
|
' dRowF("p22").ToString(),
|
|
' dRowF("p23").ToString(),
|
|
' dRowF("p24").ToString(),
|
|
' dRowF("p25").ToString(),
|
|
' dRowF("p26").ToString(),
|
|
' dRowF("q01").ToString(),
|
|
' dRowF("q02").ToString(),
|
|
' dRowF("q03").ToString(),
|
|
' dRowF("q04").ToString(),
|
|
' dRowF("q05").ToString(),
|
|
' dRowF("q06").ToString(),
|
|
' dRowF("q07").ToString(),
|
|
' dRowF("q08").ToString(),
|
|
' dRowF("q09").ToString(),
|
|
' dRowF("q10").ToString(),
|
|
' dRowF("q11").ToString(),
|
|
' dRowF("q12").ToString(),
|
|
' dRowF("q13").ToString(),
|
|
' dRowF("q14").ToString(),
|
|
' dRowF("q15").ToString(),
|
|
' dRowF("q16").ToString(),
|
|
' dRowF("q17").ToString(),
|
|
' dRowF("q18").ToString(),
|
|
' dRowF("q19").ToString(),
|
|
' dRowF("q20").ToString()
|
|
' },
|
|
' .processReference = New List(Of String)(9) From {
|
|
' dRowF("ox").ToString(),
|
|
' dRowF("oy").ToString(),
|
|
' dRowF("oz").ToString(),
|
|
' dRowF("xx").ToString(),
|
|
' dRowF("xy").ToString(),
|
|
' dRowF("xz").ToString(),
|
|
' dRowF("yx").ToString(),
|
|
' dRowF("yy").ToString(),
|
|
' dRowF("yz").ToString()
|
|
' }
|
|
' }
|
|
' readPart.features.Add(readFeature)
|
|
' Next
|
|
|
|
' btlObject.parts.Add(readPart)
|
|
' Next
|
|
|
|
' btlObject.parts.Sort(Function(p, q) p.x.CompareTo(q.x))
|
|
'End Sub
|
|
|
|
'Private Shared Function GetListaCutIdP() As List(Of Integer)
|
|
' Dim ListaCutId As List(Of Integer) = New List(Of Integer)()
|
|
' Dim dTab As DataTable = _ds.Tables(0)
|
|
' Dim listaTasksCount As Integer = dTab.Rows.Count
|
|
|
|
' For f As Integer = 0 To listaTasksCount - 1
|
|
' Dim nCut As Integer = CInt(dTab.Rows(f)("cutId"))
|
|
' If Not ListaCutId.Contains(nCut) Then ListaCutId.Add(nCut)
|
|
' Next
|
|
|
|
' Return ListaCutId
|
|
'End Function
|
|
|
|
'Private Shared Function GetElementSN(ByVal ElementId As Integer, ByVal ProjectId As Integer) As String
|
|
' Dim SN As String = "000"
|
|
' Dim sqlElementSN As String = "SELECT sn " & "FROM dbo.vw_Element " & "WHERE elementId = @firstId " & "AND projectId = @secondId"
|
|
|
|
' Using cn As SqlConnection = New SqlConnection(_SqlConnectionStr)
|
|
' cn.Open()
|
|
|
|
' Using sqlCommand As SqlCommand = New SqlCommand(sqlElementSN, cn)
|
|
' sqlCommand.Parameters.Add("@firstId", SqlDbType.Int)
|
|
' sqlCommand.Parameters.Add("@secondId", SqlDbType.Int)
|
|
' sqlCommand.Parameters("@firstId").Value = ElementId
|
|
' sqlCommand.Parameters("@secondId").Value = ProjectId
|
|
' Dim reader As SqlDataReader = sqlCommand.ExecuteReader()
|
|
|
|
' While reader.Read()
|
|
' SN = Convert.ToString(reader("sn"))
|
|
' End While
|
|
' End Using
|
|
' End Using
|
|
|
|
' Return SN
|
|
'End Function
|
|
|
|
'Private Shared Function GetBarLengthP(ByVal patternId As Integer, ByVal productionId As Integer) As Double
|
|
' Dim barLength As Double = 0
|
|
' Dim sqlBarLength As String = "SELECT l " & "FROM dbo.vw_Pattern " & "WHERE patternId = @firstId " & "AND productionId = @secondId"
|
|
|
|
' Using cn As SqlConnection = New SqlConnection(_SqlConnectionStr)
|
|
' cn.Open()
|
|
|
|
' Using sqlCommand As SqlCommand = New SqlCommand(sqlBarLength, cn)
|
|
' sqlCommand.Parameters.Add("@firstId", SqlDbType.Int)
|
|
' sqlCommand.Parameters.Add("@secondId", SqlDbType.Int)
|
|
' sqlCommand.Parameters("@firstId").Value = patternId
|
|
' sqlCommand.Parameters("@secondId").Value = productionId
|
|
' Dim reader As SqlDataReader = sqlCommand.ExecuteReader()
|
|
|
|
' While reader.Read()
|
|
' barLength = Convert.ToDouble(reader("l"))
|
|
' End While
|
|
' End Using
|
|
' End Using
|
|
|
|
' Return barLength
|
|
'End Function
|
|
|
|
'Private Shared Function GetBarWidthP(ByVal patternId As Integer, ByVal productionId As Integer) As Double
|
|
' Dim barWidth As Double = 0
|
|
' Dim sqlBarWidth As String = "SELECT w " & "FROM dbo.vw_Pattern " & "WHERE patternId = @firstId " & "AND productionId = @secondId"
|
|
|
|
' Using cn As SqlConnection = New SqlConnection(_SqlConnectionStr)
|
|
' cn.Open()
|
|
|
|
' Using sqlCommand As SqlCommand = New SqlCommand(sqlBarWidth, cn)
|
|
' sqlCommand.Parameters.Add("@firstId", SqlDbType.Int)
|
|
' sqlCommand.Parameters.Add("@secondId", SqlDbType.Int)
|
|
' sqlCommand.Parameters("@firstId").Value = patternId
|
|
' sqlCommand.Parameters("@secondId").Value = productionId
|
|
' Dim reader As SqlDataReader = sqlCommand.ExecuteReader()
|
|
|
|
' While reader.Read()
|
|
' barWidth = Convert.ToDouble(reader("w"))
|
|
' End While
|
|
' End Using
|
|
' End Using
|
|
|
|
' Return barWidth
|
|
'End Function
|
|
|
|
'Private Shared Function GetBarLoad90P(ByVal patternId As Integer, ByVal productionId As Integer) As Integer
|
|
' Dim nLoad90 As Integer = 0
|
|
' Dim sqlBarLength As String = "SELECT load90 " & "FROM dbo.vw_Pattern " & "WHERE patternId = @firstId " & "AND productionId = @secondId"
|
|
|
|
' Using cn As SqlConnection = New SqlConnection(_SqlConnectionStr)
|
|
' cn.Open()
|
|
|
|
' Using sqlCommand As SqlCommand = New SqlCommand(sqlBarLength, cn)
|
|
' sqlCommand.Parameters.Add("@firstId", SqlDbType.Int)
|
|
' sqlCommand.Parameters.Add("@secondId", SqlDbType.Int)
|
|
' sqlCommand.Parameters("@firstId").Value = patternId
|
|
' sqlCommand.Parameters("@secondId").Value = productionId
|
|
' Dim reader As SqlDataReader = sqlCommand.ExecuteReader()
|
|
|
|
' While reader.Read()
|
|
' nLoad90 = Convert.ToInt32(reader("load90"))
|
|
' End While
|
|
' End Using
|
|
' End Using
|
|
|
|
' Return nLoad90
|
|
'End Function
|
|
|
|
'Private Shared Function GetBarStateP(ByVal patternId As Integer, ByVal productionId As Integer) As Integer
|
|
' Dim barState As Integer = 16
|
|
' Dim sqlBarLength As String = "SELECT state " & "FROM dbo.vw_Pattern " & "WHERE patternId = @firstId " & "AND productionId = @secondId"
|
|
|
|
' Using cn As SqlConnection = New SqlConnection(_SqlConnectionStr)
|
|
' cn.Open()
|
|
|
|
' Using sqlCommand As SqlCommand = New SqlCommand(sqlBarLength, cn)
|
|
' sqlCommand.Parameters.Add("@firstId", SqlDbType.Int)
|
|
' sqlCommand.Parameters.Add("@secondId", SqlDbType.Int)
|
|
' sqlCommand.Parameters("@firstId").Value = patternId
|
|
' sqlCommand.Parameters("@secondId").Value = productionId
|
|
' Dim reader As SqlDataReader = sqlCommand.ExecuteReader()
|
|
|
|
' While reader.Read()
|
|
' barState = Convert.ToInt32(reader("state"))
|
|
' End While
|
|
' End Using
|
|
' End Using
|
|
|
|
' Return barState
|
|
'End Function
|
|
|
|
'Private Shared Function GetBarLengthO(ByVal elementId As Integer, ByVal projectId As Integer) As Double
|
|
' Dim barLength As Double = 0
|
|
' Dim dTab As DataTable = _ds.Tables(0)
|
|
' Dim listaProcessesCount As Integer = dTab.Rows.Count
|
|
|
|
' If listaProcessesCount > 0 Then
|
|
' Dim beamLength As Double = Convert.ToDouble(dTab.Rows(0)("length"))
|
|
|
|
' If beamLength < Constants.BarMaxLenForAdd Then
|
|
' barLength = beamLength + Constants.BarAddLen
|
|
' Else
|
|
' barLength = beamLength + 2 * Constants.HeadOverMat
|
|
' End If
|
|
' End If
|
|
|
|
' Return barLength
|
|
'End Function
|
|
|
|
'Private Shared Function GetPanelLengthO(ByVal elementId As Integer, ByVal projectId As Integer) As Double
|
|
' Dim panelLength As Double = 0
|
|
' Dim dTab As DataTable = _ds.Tables(0)
|
|
' Dim listaProcessesCount As Integer = dTab.Rows.Count
|
|
|
|
' If listaProcessesCount > 0 Then
|
|
' Dim wallLength As Double = Convert.ToDouble(dTab.Rows(0)("length"))
|
|
' panelLength = wallLength + 2 * Constants.PanelOverMat
|
|
' End If
|
|
|
|
' Return panelLength
|
|
'End Function
|
|
|
|
'Private Shared Function GetPanelWidthO(ByVal elementId As Integer, ByVal projectId As Integer) As Double
|
|
' Dim panelWidth As Double = 0
|
|
' Dim dTab As DataTable = _ds.Tables(0)
|
|
' Dim listaProcessesCount As Integer = dTab.Rows.Count
|
|
|
|
' If listaProcessesCount > 0 Then
|
|
' Dim wallWidth As Double = Convert.ToDouble(dTab.Rows(0)("width"))
|
|
' panelWidth = wallWidth + 2 * Constants.PanelOverMat
|
|
' End If
|
|
|
|
' Return panelWidth
|
|
'End Function
|
|
|
|
'Private Shared Function GetExePath(ByVal parameters As InOutParameters) As String
|
|
' Return parameters.Read("EGALTECH", "PATH_EXE", "")
|
|
'End Function
|
|
|
|
'Private Shared Function GetDataDir(ByVal parameters As InOutParameters) As String
|
|
' Dim DataDir As String = parameters.Read("EGALTECH", "DIR_DATA", "")
|
|
' Dim di As DirectoryInfo = New DirectoryInfo(DataDir)
|
|
' If Not di.Exists Then di.Create()
|
|
' Return DataDir
|
|
'End Function
|
|
|
|
'Private Shared Function GetBtlPath(ByVal DataDir As String, ByVal pattInfo As PatternInfo) As String
|
|
' Dim BtlDir, BtlName As String
|
|
|
|
' If pattInfo.IsFromProject Then
|
|
' BtlDir = Path.Combine(DataDir, "Projs", pattInfo.ProjectId.ToString("D4"))
|
|
' BtlName = "Part_" & pattInfo.ProjectId.ToString() & "_" + pattInfo.ElementId.ToString() & ".btl"
|
|
' Else
|
|
' BtlDir = Path.Combine(DataDir, "Prods", pattInfo.ProductionId.ToString("D4"))
|
|
' BtlName = "Bar_" & pattInfo.ProductionId.ToString() & "_" + pattInfo.PatternId.ToString() & ".btl"
|
|
' End If
|
|
|
|
' Dim di As DirectoryInfo = New DirectoryInfo(BtlDir)
|
|
' If Not di.Exists Then di.Create()
|
|
' Return Path.Combine(BtlDir, BtlName)
|
|
'End Function
|
|
|
|
'Private Shared Function GetMaxInstances(ByVal parameters As InOutParameters) As Integer
|
|
' Dim sMaxInst As String = parameters.Read("EGALTECH", "MaxInstances", "1")
|
|
' Dim nVal As Integer = Nothing
|
|
|
|
' If Not Integer.TryParse(sMaxInst, nVal) Then
|
|
' Return 1
|
|
' Else
|
|
' Return Math.Max(nVal, 1)
|
|
' End If
|
|
'End Function
|
|
|
|
'Public Function ShowTools(ByVal parameters As InOutParameters) As Boolean
|
|
' Dim ExePath As String = GetExePath(parameters)
|
|
' Dim DataDir As String = GetDataDir(parameters)
|
|
' Dim BtlPath As String = Path.Combine(DataDir, "QQQ.btl")
|
|
' Dim process As Process = New Process()
|
|
' process.StartInfo.FileName = ExePath
|
|
' process.StartInfo.Arguments = """" & BtlPath & """ " & parameters.MachineName & " 11"
|
|
' process.StartInfo.UseShellExecute = False
|
|
' process.Start()
|
|
|
|
' While Not process.HasExited
|
|
' process.Refresh()
|
|
' Thread.Sleep(50)
|
|
' End While
|
|
|
|
' Return True
|
|
'End Function
|
|
|
|
'Public Function ShowJobs(ByVal parameters As InOutParameters) As Boolean
|
|
' Dim ExePath As String = GetExePath(parameters)
|
|
' Dim DataDir As String = GetDataDir(parameters)
|
|
' Dim BtlPath As String = Path.Combine(DataDir, "QQQ.btl")
|
|
' Dim process As Process = New Process()
|
|
' process.StartInfo.FileName = ExePath
|
|
' process.StartInfo.Arguments = """" & BtlPath & """ " & parameters.MachineName & " 12"
|
|
' process.StartInfo.UseShellExecute = False
|
|
' process.Start()
|
|
|
|
' While Not process.HasExited
|
|
' process.Refresh()
|
|
' Thread.Sleep(50)
|
|
' End While
|
|
|
|
' Return True
|
|
'End Function
|
|
|
|
'Public Function UpdateMachine(ByVal parameters As InOutParameters) As Boolean
|
|
' GetMachineParams(parameters)
|
|
' Return True
|
|
'End Function
|
|
|
|
'<DllImport("kernel32", CharSet:=CharSet.Unicode)>
|
|
'Private Shared Function WritePrivateProfileString(ByVal Section As String, ByVal Key As String, ByVal Value As String, ByVal FilePath As String) As Long
|
|
|
|
' Private Shared Sub GetMachineParams(ByVal parameters As InOutParameters)
|
|
' Dim DataDir As String = GetDataDir(parameters)
|
|
' Dim DataName As String = "Essetre-" & parameters.MachineName & ".data"
|
|
' Dim DataPath As String = Path.Combine(DataDir, DataName)
|
|
' If File.Exists(DataPath) Then File.Delete(DataPath)
|
|
' _SqlConnectionStr = parameters.ConnectionString
|
|
' Dim dsOffsets As DataSet = New DataSet()
|
|
' Dim sqlOffsets As String = "SELECT [group], [key], [value] " & "FROM [ESSETRE].[dbo].[vw_MachineParam] " & "WHERE [group] = 'OFFSETS' AND configurationId = @ConfigId"
|
|
|
|
' Using cn As SqlConnection = New SqlConnection(_SqlConnectionStr)
|
|
' cn.Open()
|
|
|
|
' Using cmd As SqlCommand = New SqlCommand(sqlOffsets, cn)
|
|
' cmd.Parameters.Add("@ConfigId", SqlDbType.Int)
|
|
' cmd.Parameters("@ConfigId").Value = parameters.ConfigurationId
|
|
' Dim dataAdapter = New SqlDataAdapter(cmd)
|
|
' dsOffsets.Clear()
|
|
' dataAdapter.Fill(dsOffsets)
|
|
' End Using
|
|
' End Using
|
|
|
|
' _SqlConnectionStr = parameters.ConnectionString
|
|
' Dim dsTrave As DataSet = New DataSet()
|
|
' Dim sqlTrave As String = "SELECT [group], [key], [value] " & "FROM [ESSETRE].[dbo].[vw_MachineParam] " & "WHERE [group] = 'TRAVE' AND configurationId = @ConfigId"
|
|
|
|
' Using cn As SqlConnection = New SqlConnection(_SqlConnectionStr)
|
|
' cn.Open()
|
|
|
|
' Using cmd As SqlCommand = New SqlCommand(sqlTrave, cn)
|
|
' cmd.Parameters.Add("@ConfigId", SqlDbType.Int)
|
|
' cmd.Parameters("@ConfigId").Value = parameters.ConfigurationId
|
|
' Dim dataAdapter = New SqlDataAdapter(cmd)
|
|
' dsTrave.Clear()
|
|
' dataAdapter.Fill(dsTrave)
|
|
' End Using
|
|
' End Using
|
|
|
|
' _SqlConnectionStr = parameters.ConnectionString
|
|
' Dim dsUser As DataSet = New DataSet()
|
|
' Dim sqlUser As String = "SELECT [group], [key], [value] " & "FROM [ESSETRE].[dbo].[vw_ConfigurationParam] " & "WHERE [group] <> 'TEXTS' AND [group] <> 'PARAMS' AND configurationId = @ConfigId"
|
|
|
|
' Using cn As SqlConnection = New SqlConnection(_SqlConnectionStr)
|
|
' cn.Open()
|
|
|
|
' Using cmd As SqlCommand = New SqlCommand(sqlUser, cn)
|
|
' cmd.Parameters.Add("@ConfigId", SqlDbType.Int)
|
|
' cmd.Parameters("@ConfigId").Value = parameters.ConfigurationId
|
|
' Dim dataAdapter = New SqlDataAdapter(cmd)
|
|
' dsUser.Clear()
|
|
' dataAdapter.Fill(dsUser)
|
|
' End Using
|
|
' End Using
|
|
|
|
' Using tw = New StreamWriter(DataPath, False)
|
|
' tw.WriteLine("-- " & DataPath)
|
|
' tw.WriteLine("")
|
|
' tw.WriteLine("local Offsets = {")
|
|
|
|
' For Each table As DataTable In dsOffsets.Tables
|
|
|
|
' For Each row As DataRow In table.Rows
|
|
' Dim Key As String = row("key").ToString()
|
|
' Dim Value As String = row("value").ToString()
|
|
' tw.WriteLine(" " & Key & "=" & Value & ",")
|
|
' Next
|
|
' Next
|
|
|
|
' tw.WriteLine(" Zzz=1")
|
|
' tw.WriteLine("}")
|
|
' tw.WriteLine("")
|
|
' tw.WriteLine("local Trave = {")
|
|
|
|
' For Each table As DataTable In dsTrave.Tables
|
|
|
|
' For Each row As DataRow In table.Rows
|
|
' Dim Key As String = row("key").ToString()
|
|
' Dim Value As String = row("value").ToString()
|
|
' tw.WriteLine(" " & Key & "=" & Value & ",")
|
|
' Next
|
|
' Next
|
|
|
|
' tw.WriteLine(" Zzz=1")
|
|
' tw.WriteLine("}")
|
|
' tw.WriteLine("")
|
|
' tw.WriteLine("local User = {")
|
|
|
|
' For Each table As DataTable In dsUser.Tables
|
|
|
|
' For Each row As DataRow In table.Rows
|
|
' Dim Group As String = row("group").ToString()
|
|
' Dim Key As String = row("key").ToString()
|
|
' Dim Value As String = row("value").ToString()
|
|
' tw.WriteLine(" " & Group & "_" & Key & "=" & Value & ",")
|
|
' Next
|
|
' Next
|
|
|
|
' tw.WriteLine(" Zzz=1")
|
|
' tw.WriteLine("}")
|
|
' tw.WriteLine("")
|
|
' tw.WriteLine("local Machine = { Offsets=Offsets, Trave=Trave, User=User}")
|
|
' tw.WriteLine("return Machine")
|
|
' End Using
|
|
'End Sub
|
|
|
|
'Public Sub CollectFile(ByVal parameters As InOutParameters, ByVal collector As FileCollector)
|
|
' Dim sRoot As String = parameters.Read("EGALTECH", "DIR_EGT", "C:\TechnoEssetre7\EgalTech")
|
|
' Dim sBeamDir As String = "EgtCAM5\Beam"
|
|
' Dim sMachDir As String = "EgtCAM5\Machines\Essetre-" & parameters.MachineName
|
|
' collector.SetRoot(sRoot)
|
|
' collector.AddDirectory(Path.Combine(sRoot, sBeamDir))
|
|
' collector.AddDirectory(Path.Combine(sRoot, sMachDir))
|
|
'End Sub
|
|
|
|
End Class
|