Files
icarus/Icarus/Utility/LuaExec.vb
DarioS 9a187ac36b Icarus :
- parametri in Pu trasformati in parametri in %
- piccole modifiche per parametri con [%] e con [deg].
2022-10-29 10:29:10 +02:00

110 lines
4.6 KiB
VB.net

Imports EgtUILib
Imports EgtWPFLib5
Module LuaExec
Friend Function ExecSlice(bSlice As Boolean, bCalcTFS As Boolean) As Boolean
EgtOutLog("-- Start ExecSlice --")
Dim bOk As Boolean = True
' eseguo slice
If bSlice Then
EgtLuaCreateGlobTable("PRINT")
EgtLuaSetGlobIntVar("PRINT.PROGRAM", 1)
bOk = bOk AndAlso EgtLuaExecFile(Map.refMainWindowVM.MainWindowM.s3dPrintingDir & "\Slicing.lua")
' Cancello tavola globale
EgtLuaResetGlobVar("PRINT")
End If
If Not bCalcTFS Then Return True
' eseguo calcolo T,F,S da parametri materiale
Dim sExecPath As String = Map.refMainWindowVM.MainWindowM.s3dPrintingDir & "\CalcMachParamFromSW.lua"
If Not My.Computer.FileSystem.FileExists(sExecPath) Then
EgtOutLog("Not found 3DPrint script " & sExecPath)
Return False
End If
' Assegno i dati
Dim SelMaterialParam As Material = Map.refTopPanelVM.GetSelMaterialData()
Dim dMachiningConstant As Double = 100
If Not IsNothing(Map.refTopPanelVM.CurrMachining) Then
Dim MachiningConstant As CurrNumericMachiningParam = Map.refTopPanelVM.CurrMachining.CathegoryList.FirstOrDefault(Function(x) x.Type = MachiningCathegory.Cathegories.GENERAL).MachiningParamList.FirstOrDefault(Function(y) y.Type = MachiningParam.Params.FLOWRATE_PC)
If Not IsNothing(MachiningConstant) Then
dMachiningConstant = MachiningConstant.dValue
End If
End If
EgtLuaCreateGlobTable("MATERIAL")
EgtLuaSetGlobNumVar("MATERIAL.K", dMachiningConstant)
EgtLuaSetGlobNumVar("MATERIAL.C1", SelMaterialParam.dC1)
EgtLuaSetGlobNumVar("MATERIAL.C2", SelMaterialParam.dC2)
EgtLuaSetGlobNumVar("MATERIAL.Density", SelMaterialParam.dDensity)
EgtLuaSetGlobNumVar("MATERIAL.AMax", SelMaterialParam.dAMax)
EgtLuaSetGlobNumVar("MATERIAL.ATrg", SelMaterialParam.dATrg)
EgtLuaSetGlobNumVar("MATERIAL.AMin", SelMaterialParam.dAMin)
EgtLuaSetGlobNumVar("MATERIAL.BMax", SelMaterialParam.dBMax)
EgtLuaSetGlobNumVar("MATERIAL.BTrg", SelMaterialParam.dBTrg)
EgtLuaSetGlobNumVar("MATERIAL.BMin", SelMaterialParam.dBMin)
EgtLuaSetGlobNumVar("MATERIAL.KW", SelMaterialParam.dKW)
EgtLuaSetGlobNumVar("MATERIAL.KZ", SelMaterialParam.dKZ)
EgtLuaSetGlobNumVar("MATERIAL.KN", SelMaterialParam.dKN)
' Eseguo lo script
If EgtLuaExecFile(sExecPath) Then
bOk = True
'' Recupero i risultati
'Dim nErr As Integer = 999
'EgtLuaGetGlobIntVar("MATERIAL.ERR", nErr)
'bOk = (nErr <= 0)
'If Not bOk Then EgtOutLog("ExecSlice Err=" & nErr.ToString())
Else
EgtOutLog("Error executing Slice Exec script " & sExecPath)
bOk = False
End If
' Cancello tavola globale
EgtLuaResetGlobVar("MATERIAL")
Return bOk
End Function
Friend Function ExecGenerate() As Boolean
EgtOutLog("-- Start ExecGenerate --")
' eseguo generazione
EgtLuaCreateGlobTable("PRINT")
EgtLuaSetGlobIntVar("PRINT.PROGRAM", 1)
Dim sIsoFilePath As String = ""
Dim nTabPartId As Integer = EgtGetFirstNameInGroup(GDB_ID.ROOT, TABLE)
If nTabPartId <> GDB_ID.NULL Then
If Not EgtGetInfo(nTabPartId, KEY_ISOFILE_PATH, sIsoFilePath) Then
EgtGetCurrFilePath(sIsoFilePath)
Dim sExtension As String = ""
GetPrivateProfileString(S_PARTPROGRAM, K_EXTENSION, "", sExtension, CurrentMachine.sMachIniFile)
If String.IsNullOrWhiteSpace(sExtension) Then
sExtension = ".cnc"
End If
sIsoFilePath = System.IO.Path.ChangeExtension(sIsoFilePath, sExtension)
End If
End If
EgtLuaSetGlobStringVar("PRINT.ISOFILEPATH", sIsoFilePath)
Dim bOk As Boolean = EgtLuaExecFile(Map.refMainWindowVM.MainWindowM.s3dPrintingDir & "\GcodeGenerate.lua")
If bOk Then
Dim nErr As Integer = 999
EgtLuaGetGlobIntVar("PRINT.ERR", nErr)
bOk = (nErr <= 0)
End If
' Cancello tavola globale
EgtLuaResetGlobVar("PRINT")
Return bOk
End Function
Friend Function ExecSolid() As Boolean
EgtOutLog("-- Start ExecSolid --")
' eseguo generazione
EgtLuaCreateGlobTable("PRINT")
Dim bOk As Boolean = EgtLuaExecFile(Map.refMainWindowVM.MainWindowM.s3dPrintingDir & "\CalcSolids.lua")
If bOk Then
Dim nErr As Integer = 999
EgtLuaGetGlobIntVar("PRINT.ERR", nErr)
bOk = (nErr <= 0)
End If
' Cancello tavola globale
EgtLuaResetGlobVar("PRINT")
Return bOk
End Function
End Module