diff --git a/Designing/WinLib/WinCalculate.lua b/Designing/WinLib/WinCalculate.lua index 9829151..26df164 100644 --- a/Designing/WinLib/WinCalculate.lua +++ b/Designing/WinLib/WinCalculate.lua @@ -27,6 +27,7 @@ local XML = require( 'xml2lua') _G.package.loaded.XMLHandler = nil local XMLHandler = require( 'xml2lua_tree') +local nRedisConnectionId = 0 local s_dDowelTol = 1 local s_dSimplSolidApprox = 0.2 -- approssimazione lineare nel caso di solidi semplificati @@ -5586,12 +5587,12 @@ local function AddHardwareForSash( nFrameId, nReturnMode, OutputKitList, OutputP 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) EgtOutLog( 'Messaggio Redis pubblicato') - local bOk, Answer = EgtRedisAsyncSubscribeOneMessage( AnswerChannel, 5000) + local bOk, Answer = EgtRedisAsyncSubscribeOneMessage( nRedisConnectionId, AnswerChannel, 5000) if bOk then -- EgtOutLog( 'Risposta Redis ricevuta:' .. Answer) EgtOutLog( 'Risposta Redis ricevuta') @@ -5654,10 +5655,17 @@ end -- funzione che aggiunge l'hardware function WinCalculate.AddHardware( nAreaId, bMachiningList, bHardwareList, bPositionList, bOptionList) -- connessione a Redis - --local bRedisConnect = EgtRedisAsyncConnect( 'redis.ufficio:26379, serviceName=devel, DefaultDatabase=6, 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 bDisconnect = true + if WDG.REDISID and WDG.REDISID > 0 then + bDisconnect = false + nRedisConnectionId = WDG.REDISID + else + local bRedisConnect, nRedisConnectionId = EgtRedisAsyncConnect( 'redis.ufficio:26379, serviceName=devel, DefaultDatabase=6, keepAlive=180, connectTimeout=15000, syncTimeout=15000, asyncTimeout=15000, abortConnect=false, ssl=false, allowAdmin=true') + if not bRedisConnect then + bDisconnect = false + EgtOutLog('Errore! Impossibile connettersi con il server Redis dal Lua!') + end + end -- calcolo codice di ritorno, i.e. tipologie di conti da fare sulla ferramenta ( e.g calcolo lavorazioni, calcolo lista ferramenta, ...) local nReturnMode = 0 @@ -5679,7 +5687,9 @@ function WinCalculate.AddHardware( nAreaId, bMachiningList, bHardwareList, bPosi local OutputOptionList = {} AddHardwareRec( nAreaId, nReturnMode, OutputKitList, OutputPositionList, OutputOptionList) - --EgtRedisAsyncDisconnect() + if bDisconnect then + EgtRedisAsyncDisconnect() + end return OutputKitList, OutputPositionList, OutputOptionList end