- commentato onlyoption in Agb

- aggiunte linee di debug per processi
- aggiunta modalita' hardware, config, order, verify
- migliorato png delle travi
- aggiunto volume in BOM
- aggiunto sanitizeUtf8
- spostata connessione Redis a inizio file
- gestite chiamate REST per beam
- gestita verifica non parallela per travi
- aggiunte opzioni hardware finestre
- aggiunta calcolo forma anta finestra
This commit is contained in:
Emmanuele Sassi
2025-12-09 18:11:46 +01:00
parent 8e485aac69
commit a1700f635c
6 changed files with 1098 additions and 93 deletions
+185 -36
View File
@@ -24,6 +24,7 @@ QUESTION_MODES = {
BOM = 2,
HARDWARE = 3,
CONFIG = 4,
ORDER = 5,
}
QUESTION_CONFIG_SUBMODES = {
@@ -58,9 +59,18 @@ EgtAddToPackagePath( sBaseDir .. '\\Designing\\?.lua')
_G.package.loaded.WinProject = nil
local WinProject = require( 'WinProject')
-- Connessiona a Redis
local bRedisConnect, nRedisConnectionId = EgtRedisAsyncConnect( ENG.Param2)
if bRedisConnect then
EgtOutLog('Connessione con il server Redis dal Lua effettuata con successo con Id=' .. nRedisConnectionId .. '!')
else
nRedisConnectionId = 0
EgtOutLog('Errore! Impossibile connettersi con il server Redis dal Lua!')
end
local function Calc_Preview( QuestionArgs)
-- leggo argomenti passati
local sJwd = QuestionArgs["Jwd"]
local sJwd = QuestionArgs["SerializedData"]
if sJwd and #sJwd > 0 then
-- imposto cartella profili
local sProfileDir = ''
@@ -89,10 +99,10 @@ local function Calc_Preview( QuestionArgs)
WinCalculate_CreatePartFromArea()
-- calcolo hardware
--WDG.FRAMEID = AreaId
WDG.CALC_HARDWARELIST=false
WDG.CALC_POSITIONLIST=false
WDG.CALC_MACHININGLIST=false
WDG.CALC_OPTIONLIST=false
--WDG.CALC_HARDWARELIST=false
--WDG.CALC_POSITIONLIST=false
--WDG.CALC_MACHININGLIST=false
--WDG.CALC_OPTIONLIST=false
--WinCalculate_AddHardware()
-- creo file svg
@@ -119,7 +129,7 @@ end
local function Calc_BOM( QuestionArgs)
-- leggo argomenti passati
local sJwd = QuestionArgs["Jwd"]
local sJwd = QuestionArgs["SerializedData"]
if sJwd and #sJwd > 0 then
-- imposto cartella profili
local sProfileDir = ''
@@ -141,7 +151,7 @@ local function Calc_BOM( QuestionArgs)
_G.WinCalculate_SetCalcSolid()
WDG.VALUE = false
WinCalculate_SetSimplifiedSolid()
WDG.VALUE = true
WDG.VALUE = false
WinCalculate_SetCalcPreview()
-- creazione pezzi
WDG.FRAMEID = AreaId
@@ -208,7 +218,7 @@ local function Calc_BOM( QuestionArgs)
end
end
local function Calc_Hardware( QuestionArgs, sReadLine)
local function Calc_HardwareList( QuestionArgs, sReadLine)
local nManufacturer = tonumber( QuestionArgs["Manufacturer"])
if nManufacturer == MANUFACTURERS.AGB then
-- Canali
@@ -220,11 +230,11 @@ local function Calc_Hardware( QuestionArgs, sReadLine)
local JsonQuestion = JSON:encode( Question)
local bOk = EgtRedisAsyncPublish( QuestionChannel, JsonQuestion)
local bOk = EgtRedisAsyncPublish( nRedisConnectionId, QuestionChannel, JsonQuestion)
local AnswerArgs
if bOk then
EgtOutLog('Messaggio Redis pubblicato:' .. QuestionChannel .. ' ' .. JsonQuestion)
local bOk, Answer = EgtRedisAsyncSubscribeOneMessage( AnswerChannel, 10000)
local bOk, Answer = EgtRedisAsyncSubscribeOneMessage( nRedisConnectionId, AnswerChannel, 10000)
if bOk then
EgtOutLog('Risposta Redis ricevuta:' .. Answer)
local JsonAnswer = JSON:decode( Answer)
@@ -245,12 +255,150 @@ local function Calc_Hardware( QuestionArgs, sReadLine)
end
end
local function Calc_HardwareOptions( QuestionArgs)
-- leggo argomenti passati
local sJwd = QuestionArgs["SerializedData"]
local JsonGroupId = QuestionArgs["GroupId"]
if sJwd and JsonGroupId and #sJwd > 0 and #JsonGroupId > 0 then
-- imposto cartella profili
local sProfileDir = ''
sProfileDir = EgtGetStringFromIni( 'Window', 'ProfileDir', '', sIniFilePath)
if sProfileDir and #sProfileDir > 0 then
WDG.PROFILEPATH = sProfileDir
SetProfilePath()
else
local sErrorMsg = 'Errore! Cartella dei profili non trovata!'
EgtOutLog(sErrorMsg)
return 0, { Error = sErrorMsg}
end
local GroupId = JSON:decode( JsonGroupId)
-- carico jwd
WDG.JWD = sJwd
WinManage_LoadJwd()
local AreaId = WDG.AREAID
-- imposto opzioni visualizzazione
WDG.VALUE = false
_G.WinCalculate_SetCalcSolid()
WDG.VALUE = false
WinCalculate_SetSimplifiedSolid()
WDG.VALUE = false
WinCalculate_SetCalcPreview()
-- creazione pezzi
WDG.FRAMEID = AreaId
WinCalculate_CreatePartFromArea()
-- calcolo hardware
for i = 1, #GroupId do
WDG['AREANBR' .. tostring(i)] = GroupId[i]
end
WDG.FRAMEID = AreaId
WDG.CALC_MACHINING=false
WDG.CALC_HARDWARELIST=false
WDG.CALC_POSITIONLIST=false
WDG.CALC_OPTIONLIST=true
WinCalculate_AddHardwareByGroupId()
local nCalcHardwareOption = 0
local AnswerGroupId = {}
for i = 1, #GroupId do
local HardwareOptionList = WDG['HARDWAREOPTION_LIST' .. tostring(i)]
if HardwareOptionList then
nCalcHardwareOption = nCalcHardwareOption + 1
AnswerGroupId[ tostring( GroupId[i])] = HardwareOptionList[1]
else
AnswerGroupId[ tostring( GroupId[i])] = ''
end
end
if nCalcHardwareOption == #GroupId then
local JsonAnswerGroupId = JSON:encode( AnswerGroupId)
return 1, { HardwareOptions = JsonAnswerGroupId, GroupId = JsonGroupId}
elseif nCalcHardwareOption == 0 then
return 0, { Error = "Errore! Lista opzioni hardware non trovata!", GroupId = JsonGroupId}
end
--if WDG.HARDWAREOPTION_LIST and #WDG.HARDWAREOPTION_LIST > 0 then
-- return 1, { HardwareOptions = WDG.HARDWAREOPTION_LIST[1]}
--else
-- return 0, { Error = "Errore! Opzioni hardware non trovate!"}
--end
else
local sErrorMsg = 'Errore! Jwd non trovato!'
EgtOutLog(sErrorMsg)
return 0, { Error = sErrorMsg}
end
end
local function Calc_SashShape( QuestionArgs)
-- leggo argomenti passati
local sJwd = QuestionArgs["SerializedData"]
local JsonGroupId = QuestionArgs["GroupId"]
if sJwd and JsonGroupId and #sJwd > 0 and #JsonGroupId > 0 then
-- imposto cartella profili
local sProfileDir = ''
sProfileDir = EgtGetStringFromIni( 'Window', 'ProfileDir', '', sIniFilePath)
if sProfileDir and #sProfileDir > 0 then
WDG.PROFILEPATH = sProfileDir
SetProfilePath()
else
local sErrorMsg = 'Errore! Cartella dei profili non trovata!'
EgtOutLog(sErrorMsg)
return 0, { Error = sErrorMsg}
end
local GroupId = JSON:decode( JsonGroupId)
-- carico jwd
WDG.JWD = sJwd
WinManage_LoadJwd()
local AreaId = WDG.AREAID
-- imposto opzioni visualizzazione
WDG.VALUE = false
_G.WinCalculate_SetCalcSolid()
WDG.VALUE = false
WinCalculate_SetSimplifiedSolid()
WDG.VALUE = false
WinCalculate_SetCalcPreview()
-- creazione pezzi
--WDG.FRAMEID = AreaId
--WinCalculate_CreatePartFromArea()
for i = 1, #GroupId do
WDG['AREANBR' .. tostring(i)] = GroupId[i]
end
WinGetSashShape()
local nCalcShape = 0
local AnswerGroupId = {}
for i = 1, #GroupId do
local SashShape = WDG['SASHSHAPE' .. tostring(i)]
if SashShape then
nCalcShape = nCalcShape + 1
AnswerGroupId[ tostring( GroupId[i])] = SashShape
else
AnswerGroupId[ tostring( GroupId[i])] = ''
end
end
if nCalcShape == #GroupId then
local JsonAnswerGroupId = JSON:encode( AnswerGroupId)
return 1, { SashShape = JsonAnswerGroupId, GroupId = JsonGroupId}
else
return 0, { Error = "Errore! Forma serramento non trovata!", GroupId = JsonGroupId}
end
else
local sErrorMsg = 'Errore! Jwd o GroupId non trovato!'
EgtOutLog(sErrorMsg)
return 0, { Error = sErrorMsg, GroupId = JsonGroupId}
end
end
local function Calc_ProfileList()
-- leggo cartella profili
local sProfileDir = ''
sProfileDir = EgtGetStringFromIni( 'Window', 'ProfileDir', '', sIniFilePath)
if sProfileDir and #sProfileDir > 0 then
local Profiles = EgtFindAllFiles( sProfileDir)
local Profiles = EgtFindAllFiles( sProfileDir .. '\\*.nge')
for i = 1, #Profiles do
_, Profiles[i], _ = EgtSplitPath( Profiles[i])
end
local ProfilesBOM = JSON:encode( Profiles)
return 1, { ProfileList = ProfilesBOM}
else
@@ -264,26 +412,6 @@ local nErr = 999
local nNilCount = 0
local bRun = true
--local sRedisConnection = ENG.Param2
--local RedisConnectionParamList = EgtSplitString( sRedisConnection, ',')
--local sRedisAddressPort = RedisConnectionParamList[1]
--sRedisAddressPort, _ = EgtReplaceString( sRedisAddressPort, 'server=', '')
--local RedisAddressPortLi st = EgtSplitString( sRedisAddressPort, ':')
--local nDefaultDatabase = ''
--for nIndex = 2, #RedisConnectionParamList do
-- local sParam = ''
-- local nParam = 0
-- sParam, nParam = EgtReplaceString( RedisConnectionParamList[nIndex], 'DefaultDatabase=', '')
-- if nParam == 1 then
-- nDefaultDatabase = tonumber( EgtTrim( sParam))
-- end
--end
local bRedisConnect = EgtRedisAsyncConnect( ENG.Param2)
--local bRedisConnect = EgtRedisAsyncConnect( 'redis02.ufficio:6378, serviceName=devel, DefaultDatabase=0, keepAlive=180, connectTimeout=15000, syncTimeout=15000, asyncTimeout=15000, abortConnect=false, ssl=false, allowAdmin=true')
if not bRedisConnect then
EgtOutLog('Errore! Impossibile connettersi con il server Redis dal Lua!')
end
local size = 2^13 -- good buffer size (8K)
while bRun do
local sReadLine = io.stdin:read( 'l')
@@ -311,15 +439,36 @@ while bRun do
local sUid = QuestionArgs["UID"]
local nMode = tonumber( QuestionArgs["Mode"])
_G.WDG = {}
-- esecuzione della corretta modilita'
EgtOutLog('Esecuzione calcolo')
WDG.REDISID = nRedisConnectionId
-- esecuzione della corretta modalita'
EgtOutLog('Ricevuta richiesta calcolo: nThreadIndex=' .. nThreadIndex .. ', nId=' .. nId .. ', UID=' .. sUid .. ', nMode=' .. nMode)
local Result = {}
if nMode == QUESTION_MODES.PREVIEW then
nResult, AnswerArgs = Calc_Preview( QuestionArgs)
elseif nMode == QUESTION_MODES.BOM then
nResult, AnswerArgs = Calc_BOM( QuestionArgs)
elseif nMode == QUESTION_MODES.HARDWARE then
nResult, AnswerArgs = Calc_Hardware( QuestionArgs, sReadLine)
if QuestionArgs.SubMode then
local nSubMode = tonumber( QuestionArgs["SubMode"])
EgtOutLog('SubMode=' .. nSubMode)
if nSubMode == QUESTION_HARDWARE_SUBMODES.LIST then
nResult, AnswerArgs = Calc_HardwareList( QuestionArgs, sReadLine)
elseif nSubMode == QUESTION_HARDWARE_SUBMODES.HARDWAREOPTION then
nResult, AnswerArgs = Calc_HardwareOptions( QuestionArgs)
elseif nSubMode == QUESTION_HARDWARE_SUBMODES.SASHSHAPE then
nResult, AnswerArgs = Calc_SashShape( QuestionArgs)
else
nResult = 0
local sErrorMsg = 'Errore! Valore di SubMode errato!'
AnswerArgs = { Error = sErrorMsg}
EgtOutLog( sErrorMsg)
end
else
nResult = 0
local sErrorMsg = 'Errore! Domanda senza SubMode che é obbligatorio!'
AnswerArgs = { Error = sErrorMsg}
EgtOutLog( sErrorMsg)
end
elseif nMode == QUESTION_MODES.CONFIG then
if QuestionArgs.SubMode then
local nSubMode = tonumber( QuestionArgs["SubMode"])
@@ -358,7 +507,7 @@ while bRun do
nResult = nResult,
Args = AnswerArgs}
-- invio risposta
EgtOutLog( 'Invio risposta')
EgtOutLog('Invio risposta: nThreadIndex=' .. nThreadIndex .. ', nId=' .. nId .. ', nResult=' .. nResult)
local JsonResult = JSON:encode( Result)
io.stdout:write( "#8376261#" .. JsonResult .. "#8376261#" .. '\n')
io.stdout:flush()
@@ -375,4 +524,4 @@ while bRun do
end
end
EgtRedisAsyncDisconnect()
EgtRedisAsyncDisconnect( nRedisConnectionId)