Aggiunti file
This commit is contained in:
+473
@@ -0,0 +1,473 @@
|
||||
--
|
||||
-- EEEEEEEEEE GGGGGG TTTTTTTTTTTTTT
|
||||
-- EEEEEEEEEE GGGGGGGGGG TTTTTTTTTTTTTT
|
||||
-- EEEE GGGG GGGG TTTT
|
||||
-- EEEE GGGG TTTT
|
||||
-- EEEEEEE GGGG GGGGGGG TTTT
|
||||
-- EEEEEEE GGGG GGGGGGG TTTT
|
||||
-- EEEE GGGG GGGG TTTT
|
||||
-- EEEE GGGG GGGG TTTT
|
||||
-- EEEEEEEEEE GGGGGGGGGG TTTT
|
||||
-- EEEEEEEEEE GGGGGG TTTT
|
||||
--
|
||||
-- by Egalware s.r.l.
|
||||
-- Door manager by Egalware s.r.l. 2023/05/09
|
||||
|
||||
require( 'EgtBase')
|
||||
_ENV = EgtProtectGlobal()
|
||||
EgtEnableDebug( true)
|
||||
|
||||
-- modalita' di chiamata
|
||||
QUESTION_MODES = {
|
||||
NULL = 0,
|
||||
PREVIEW = 1,
|
||||
BOM = 2,
|
||||
HARDWARE = 3,
|
||||
CONFIG = 4,
|
||||
}
|
||||
|
||||
-- modalita' di chiamata
|
||||
QUESTION_HARDWARE_SUBMODES = {
|
||||
NULL = 0,
|
||||
LIST = 1,
|
||||
CALCHARDWARE = 2,
|
||||
HARDWAREOPTION = 3,
|
||||
}
|
||||
|
||||
-- produttore
|
||||
MANUFACTURERS = {
|
||||
NULL = 0,
|
||||
AGB = 1,
|
||||
MAICO = 2,
|
||||
ROTO = 3,
|
||||
}
|
||||
|
||||
OPENINGTYPES = {
|
||||
NULL = 0,
|
||||
TURNONLY = 1,
|
||||
TILTTURN = 2,
|
||||
TILTONLY = 3,
|
||||
PIVOT = 4,
|
||||
FIXED = 5,
|
||||
COMPLANARSLIDE = 6,
|
||||
LIFTSLIDE = 7
|
||||
}
|
||||
|
||||
_G.package.loaded.JSON = nil
|
||||
local JSON = require( 'JSON')
|
||||
|
||||
local sIniFilePath = EgtGetIniFile()
|
||||
--local sBaseDir = EgtGetStringFromIni( 'Window', 'BaseDir', '', sIniFilePath)
|
||||
--EgtAddToPackagePath( sBaseDir .. '\\Designing\\?.lua')
|
||||
----EgtAddToPackagePath( sBaseDir .. '\\Machining\\?.lua')
|
||||
--
|
||||
--_G.package.loaded.WinProject = nil
|
||||
--local WinProject = require( 'WinProject')
|
||||
|
||||
-- creo seed random utilizzando data e clock della CPU che fornisce i decimali di secondo
|
||||
math.randomseed( os.time() + math.floor( os.clock() * 1000000000))
|
||||
|
||||
local function AGBHardwareShapeConverter( sShape)
|
||||
if sShape == 'R' then
|
||||
return 'Rectangular'
|
||||
elseif sShape == 'T' then
|
||||
return 'Trapezoidal'
|
||||
elseif sShape == 'AS' then
|
||||
return 'FullArc'
|
||||
elseif sShape == 'AR' then
|
||||
return 'Arc'
|
||||
elseif sShape == 'SS' then
|
||||
return 'SemiFullArc'
|
||||
elseif sShape == 'SR' then
|
||||
return 'SemiArc'
|
||||
elseif sShape == 'C' then
|
||||
return 'Circular'
|
||||
end
|
||||
end
|
||||
|
||||
local function AGBHardwareOpeningTypesConverter( sOpeningType)
|
||||
if sOpeningType == 'AR' then
|
||||
return 'TiltTurn'
|
||||
elseif sOpeningType == 'AB' then
|
||||
return 'TurnOnly'
|
||||
elseif sOpeningType == 'CO' then
|
||||
return 'ComplanarSlide'
|
||||
elseif sOpeningType == 'AS' then
|
||||
return 'LiftSlide'
|
||||
elseif sOpeningType == 'BI' then
|
||||
return 'Pivot'
|
||||
elseif sOpeningType == 'VA' then
|
||||
return 'TiltOnly'
|
||||
end
|
||||
end
|
||||
|
||||
local function Calc_HardwareModelList( nManufacturer)
|
||||
-- leggo argomenti passati
|
||||
if nManufacturer == MANUFACTURERS.AGB then
|
||||
local sNow = os.date( '_%Y_%m_%d_%H_%M_%S', os.time())
|
||||
local nRandomAdd = math.random( 1, 9999999999)
|
||||
local sIdentifier = sNow .. '_' .. string.format( '%010d', nRandomAdd)
|
||||
local sInputFileDir = EgtGetStringFromIni( 'AGB', 'InputFileDir', 'A:\\InputBatch', sIniFilePath)
|
||||
local sInputFile = sInputFileDir .. '\\Input' .. sNow .. '.txt'
|
||||
local sAGBOutputFileDir = EgtGetStringFromIni( 'AGB', 'AGBOutputFileDir', 'C:\\AGB3000NG\\OutputBatch', sIniFilePath)
|
||||
local sAGBOutputKitFile = sAGBOutputFileDir .. '\\Output' .. sNow .. '.txt'
|
||||
local sOutputFileDir = EgtGetStringFromIni( 'AGB', 'OutputFileDir', 'A:\\OutputBatch', sIniFilePath)
|
||||
local sOutputKitFile = sOutputFileDir .. '\\Output' .. sNow .. '.txt'
|
||||
-- Apro file Input in scrittura
|
||||
local fhInput = io.open( sInputFile, 'w')
|
||||
if not fhInput then
|
||||
EgtOutLog( 'Error opening file ' .. sInputFile)
|
||||
return false
|
||||
end
|
||||
|
||||
local sText = 'OUTPUTKIT=' .. sAGBOutputKitFile .. '\n' ..
|
||||
'DATAREQUEST=SE\n' ..
|
||||
'RUN'
|
||||
|
||||
-- Scrittura nuova linea
|
||||
fhInput:write( sText .. '\n')
|
||||
|
||||
-- Chiudo file
|
||||
fhInput:close()
|
||||
|
||||
-- attendo scrittura output
|
||||
local nWait = 0
|
||||
while not EgtExistsFile( sOutputKitFile) and nWait < 500 do
|
||||
nWait = nWait + 1
|
||||
EgtPause( 10, true)
|
||||
end
|
||||
|
||||
EgtPause( 10, true)
|
||||
|
||||
local OutputKit = {}
|
||||
-- Apro file OutputKit in lettura
|
||||
local fhOutputKit = io.open( sOutputKitFile, 'r')
|
||||
if not fhOutputKit then
|
||||
EgtOutLog( 'Error opening file ' .. sOutputKitFile)
|
||||
return false
|
||||
end
|
||||
local nKitLineIndex = 1
|
||||
for sLine in fhOutputKit:lines('l') do
|
||||
local KitParams = EgtSplitString( sLine, ';')
|
||||
local DescriptionSplit = EgtSplitString( KitParams[4], '_')
|
||||
OutputKit[nKitLineIndex] = { Id = KitParams[3], FamilyName = DescriptionSplit[1], Description = KitParams[4], OpeningType = AGBHardwareOpeningTypesConverter( KitParams[5]), Shape = AGBHardwareShapeConverter(KitParams[6]), SashQty = tonumber(KitParams[7]), SashPosition = tonumber(KitParams[8])}
|
||||
nKitLineIndex = nKitLineIndex + 1
|
||||
end
|
||||
-- Chiudo file OutputKit in lettura
|
||||
fhOutputKit:close()
|
||||
-- elimino file creati
|
||||
EgtEraseFile( sInputFile)
|
||||
EgtEraseFile( sOutputKitFile)
|
||||
local JsonOutputKit = JSON:encode( OutputKit)
|
||||
return 1, { HardwareModelList = JsonOutputKit}
|
||||
else
|
||||
local sErrorMsg = 'Errore! Produttore ' .. nManufacturer .. ' non gestito!'
|
||||
EgtOutLog(sErrorMsg)
|
||||
return 0, { Error = sErrorMsg}
|
||||
end
|
||||
end
|
||||
|
||||
local function Calc_WindowHardware( nManufacturer, QuestionArgs)
|
||||
-- leggo argomenti passati
|
||||
if nManufacturer == MANUFACTURERS.AGB then
|
||||
local sNow = os.date( '_%Y_%m_%d_%H_%M_%S', os.time())
|
||||
local nRandomAdd = math.random( 1, 9999999999)
|
||||
local sIdentifier = sNow .. '_' .. string.format( '%010d', nRandomAdd)
|
||||
local sInputFileDir = EgtGetStringFromIni( 'AGB', 'InputFileDir', 'A:\\InputBatch', sIniFilePath)
|
||||
local sInputFile = sInputFileDir .. '\\Input' .. sNow .. '.txt'
|
||||
local sAGBOutputFileDir = EgtGetStringFromIni( 'AGB', 'AGBOutputFileDir', 'C:\\AGB3000NG\\OutputBatch', sIniFilePath)
|
||||
local sOutputFileDir = EgtGetStringFromIni( 'AGB', 'OutputFileDir', 'A:\\OutputBatch', sIniFilePath)
|
||||
local sAGBOutputKitFile = sAGBOutputFileDir .. '\\Output' .. sNow .. '.txt'
|
||||
local sAGBOutputPositionFile = sAGBOutputFileDir .. '\\OutputPosition' .. sNow .. '.txt'
|
||||
local sAGBOutputLavFile = sAGBOutputFileDir .. '\\OutputLav' .. sNow .. '.txt'
|
||||
local sOutputKitFile = sOutputFileDir .. '\\Output' .. sNow .. '.txt'
|
||||
local sOutputPositionFile = sOutputFileDir .. '\\OutputPosition' .. sNow .. '.txt'
|
||||
local sOutputMachiningFile = sOutputFileDir .. '\\OutputLav' .. sNow .. '.txt'
|
||||
local sInputOptionFile = sInputFileDir .. '\\Input' .. sNow .. '.opt'
|
||||
|
||||
-- Apro file Input in scrittura
|
||||
local fhInput = io.open( sInputFile, 'w')
|
||||
if not fhInput then
|
||||
EgtOutLog( 'Error opening file ' .. sInputFile)
|
||||
return false
|
||||
end
|
||||
|
||||
local ReturnMode = tonumber( QuestionArgs['ReturnMode'])
|
||||
local HardwareListFlag = ( ReturnMode & 1) ~= 0
|
||||
local HardwarePositionListFlag = ( ReturnMode & 2) ~= 0
|
||||
local MachiningListFlag = ( ReturnMode & 4) ~= 0
|
||||
local HardwareOptionListFlag = ( ReturnMode & 8) ~= 0
|
||||
local sInput = QuestionArgs['Input']
|
||||
local sText = ''
|
||||
if HardwareListFlag then
|
||||
sText = sText .. 'OUTPUTKIT=' .. sAGBOutputKitFile .. '\n' ..
|
||||
'EXTINFO=ON\n'
|
||||
end
|
||||
if MachiningListFlag then
|
||||
sText = sText .. 'CNCOUTPUT=' .. sAGBOutputLavFile .. '\n'
|
||||
end
|
||||
if HardwarePositionListFlag then
|
||||
sText = sText .. 'OUTPUTARTICLEPOSITION=' .. sAGBOutputPositionFile .. '\n'
|
||||
end
|
||||
if HardwareOptionListFlag and not HardwareListFlag and not MachiningListFlag and not HardwarePositionListFlag then
|
||||
sText = sText .. 'OUTPUTKIT=' .. sAGBOutputKitFile .. '\n'
|
||||
sText = sText .. 'only_options=on\n'
|
||||
end
|
||||
sText = sText .. sInput
|
||||
sText = sText .. 'RUN'
|
||||
|
||||
-- Scrittura nuova linea
|
||||
fhInput:write( sText .. '\n')
|
||||
|
||||
-- Chiudo file
|
||||
fhInput:close()
|
||||
|
||||
|
||||
local OptionList = ''
|
||||
if HardwareOptionListFlag then
|
||||
|
||||
-- attendo scrittura OptionList
|
||||
local nWait = 0
|
||||
while not EgtExistsFile( sInputOptionFile) and nWait < 500 do
|
||||
nWait = nWait + 1
|
||||
EgtPause( 10, true)
|
||||
end
|
||||
|
||||
EgtPause( 10, true)
|
||||
|
||||
-- Apro file OptionList in lettura
|
||||
local fhOptionList = io.open( sInputOptionFile, 'r')
|
||||
if not fhOptionList then
|
||||
EgtOutLog( 'Error opening file ' .. sInputOptionFile)
|
||||
return false
|
||||
end
|
||||
OptionList = fhOptionList:read('*a')
|
||||
-- Chiudo file OutputKit in lettura
|
||||
fhOptionList:close()
|
||||
end
|
||||
|
||||
local sHardwareList = ''
|
||||
if HardwareListFlag then
|
||||
|
||||
-- attendo scrittura OptionList
|
||||
local nWait = 0
|
||||
while not EgtExistsFile( sOutputKitFile) and nWait < 500 do
|
||||
nWait = nWait + 1
|
||||
EgtPause( 10, true)
|
||||
end
|
||||
|
||||
EgtPause( 10, true)
|
||||
|
||||
local HardwareList = {}
|
||||
-- Apro file OptionList in lettura
|
||||
local fhHardwareList = io.open( sOutputKitFile, 'r')
|
||||
if not fhHardwareList then
|
||||
EgtOutLog( 'Error opening file ' .. sOutputKitFile)
|
||||
return false
|
||||
end
|
||||
local nHardwareLineIndex = 1
|
||||
for sLine in fhHardwareList:lines('l') do
|
||||
local HardwareListParams = EgtSplitString( sLine, ';')
|
||||
HardwareList[nHardwareLineIndex] = { Id = HardwareListParams[1], Qty = tonumber( HardwareListParams[2]), ArtCode = HardwareListParams[3], Description = HardwareListParams[4], UM = HardwareListParams[5], Price = tonumber(HardwareListParams[6]), Weight = tonumber(HardwareListParams[7])}
|
||||
nHardwareLineIndex = nHardwareLineIndex + 1
|
||||
end
|
||||
-- Chiudo file OutputKit in lettura
|
||||
fhHardwareList:close()
|
||||
sHardwareList = JSON:encode( HardwareList)
|
||||
end
|
||||
|
||||
local sMachiningList = ''
|
||||
if MachiningListFlag then
|
||||
|
||||
-- attendo scrittura OptionList
|
||||
local nWait = 0
|
||||
while not EgtExistsFile( sOutputMachiningFile) and nWait < 500 do
|
||||
nWait = nWait + 1
|
||||
EgtPause( 10, true)
|
||||
end
|
||||
|
||||
EgtPause( 10, true)
|
||||
|
||||
local MachiningList = {}
|
||||
-- Apro file OptionList in lettura
|
||||
local fhMachiningList = io.open( sOutputMachiningFile, 'r')
|
||||
if not fhMachiningList then
|
||||
EgtOutLog( 'Error opening file ' .. sOutputMachiningFile)
|
||||
return false
|
||||
end
|
||||
local nMachiningLineIndex = 1
|
||||
for sLine in fhMachiningList:lines('l') do
|
||||
local MachiningListParams = EgtSplitString( sLine, ';')
|
||||
MachiningList[nMachiningLineIndex] = { RecordID = MachiningListParams[1], Sequence = MachiningListParams[2], WindowPart = MachiningListParams[3], SashIndex = tonumber( MachiningListParams[4]), SashPart = MachiningListParams[5], PosX = tonumber(MachiningListParams[6]), PosY = tonumber(MachiningListParams[7]), PosZ = tonumber(MachiningListParams[8]),
|
||||
Macro = MachiningListParams[9], AngleXY = tonumber( MachiningListParams[10]), AngleXZ = tonumber( MachiningListParams[11]), AngleYZ = tonumber( MachiningListParams[12]), RasabilitySup = tonumber( MachiningListParams[13]), RasabilityInf = tonumber( MachiningListParams[14]), Dimension = MachiningListParams[15],
|
||||
Direction = tonumber( MachiningListParams[16]), Name = MachiningListParams[17], Description = MachiningListParams[18], ArtCode = MachiningListParams[19], ArtDescription = MachiningListParams[20], Side = MachiningListParams[21], Screw = tonumber(MachiningListParams[22]), Screwdriver = tonumber( MachiningListParams[23]),
|
||||
Origin = MachiningListParams[24], Qty = tonumber( MachiningListParams[25])}
|
||||
nMachiningLineIndex = nMachiningLineIndex + 1
|
||||
end
|
||||
-- Chiudo file OutputKit in lettura
|
||||
fhMachiningList:close()
|
||||
sMachiningList = JSON:encode( MachiningList)
|
||||
end
|
||||
|
||||
local sPositionList = ''
|
||||
if HardwarePositionListFlag then
|
||||
|
||||
-- attendo scrittura OptionList
|
||||
local nWait = 0
|
||||
while not EgtExistsFile( sOutputPositionFile) and nWait < 500 do
|
||||
nWait = nWait + 1
|
||||
EgtPause( 10, true)
|
||||
end
|
||||
|
||||
EgtPause( 10, true)
|
||||
|
||||
local PositionList = {}
|
||||
-- Apro file OptionList in lettura
|
||||
local fhPositionList = io.open( sOutputPositionFile, 'r')
|
||||
if not fhPositionList then
|
||||
EgtOutLog( 'Error opening file ' .. sOutputPositionFile)
|
||||
return false
|
||||
end
|
||||
local nPositionLineIndex = 1
|
||||
for sLine in fhPositionList:lines('l') do
|
||||
local PositionListParams = EgtSplitString( sLine, ';')
|
||||
PositionList[nPositionLineIndex] = { RecordID = PositionListParams[1], Sequence = PositionListParams[2], WindowPart = PositionListParams[3], SashIndex = tonumber( PositionListParams[4]), SashPart = PositionListParams[5], PosX = tonumber(PositionListParams[6]), PosY = tonumber(PositionListParams[7]), PosZ = tonumber(PositionListParams[8]),
|
||||
Macro = PositionListParams[9], ArticlePosX = tonumber( PositionListParams[10]), ArticlePosY = tonumber( PositionListParams[11]), ArticlePosZ = tonumber( PositionListParams[12]), RasabilitySup = tonumber( PositionListParams[13]), RasabilityInf = tonumber( PositionListParams[14]), Dimension = PositionListParams[15],
|
||||
Direction = tonumber( PositionListParams[16]), Name = PositionListParams[17], Description = PositionListParams[18], ArtCode = PositionListParams[19], ArtDescription = PositionListParams[20], Side = PositionListParams[21], Screw = tonumber(PositionListParams[22]), Screwdriver = tonumber( PositionListParams[23]),
|
||||
Origin = PositionListParams[24], Qty = tonumber( PositionListParams[25]), PosXMarker = tonumber( PositionListParams[26]), PosYMarker = tonumber( PositionListParams[27]), PosXxDes = tonumber( PositionListParams[28]), PosYxDes = tonumber( PositionListParams[29]), QuotaxDes = PositionListParams[30]}
|
||||
nPositionLineIndex = nPositionLineIndex + 1
|
||||
end
|
||||
-- Chiudo file OutputKit in lettura
|
||||
fhPositionList:close()
|
||||
sPositionList = JSON:encode( PositionList)
|
||||
end
|
||||
|
||||
--local OutputKit = {}
|
||||
---- Apro file OutputKit in lettura
|
||||
--local fhOutputKit = io.open( sOutputKitFile, 'r')
|
||||
--if not fhOutputKit then
|
||||
-- EgtOutLog( 'Error opening file ' .. sOutputKitFile)
|
||||
-- return false
|
||||
--end
|
||||
--local nKitLineIndex = 1
|
||||
--for sLine in fhOutputKit:lines('l') do
|
||||
-- local KitParams = EgtSplitString( sLine, ';')
|
||||
-- local DescriptionSplit = EgtSplitString( KitParams[4], '_')
|
||||
-- OutputKit[nKitLineIndex] = { Id = KitParams[3], FamilyName = DescriptionSplit[1], Description = KitParams[4], OpeningType = KitParams[5], Shape = KitParams[6], SashQty = tonumber(KitParams[7]), SashPosition = tonumber(KitParams[8])}
|
||||
-- nKitLineIndex = nKitLineIndex + 1
|
||||
--end
|
||||
---- Chiudo file OutputKit in lettura
|
||||
--fhOutputKit:close()
|
||||
|
||||
--local JsonOutputKit = JSON:encode( OutputKit)
|
||||
local AnswerArgs = { OptionList = OptionList,
|
||||
HardwareList = sHardwareList,
|
||||
MachiningList = sMachiningList,
|
||||
PositionList = sPositionList}
|
||||
return 1, AnswerArgs
|
||||
else
|
||||
local sErrorMsg = 'Errore! Produttore ' .. nManufacturer .. ' non gestito!'
|
||||
EgtOutLog(sErrorMsg)
|
||||
return 0, { Error = sErrorMsg}
|
||||
end
|
||||
end
|
||||
|
||||
local nErr = 999
|
||||
local nNilCount = 0
|
||||
local bRun = true
|
||||
|
||||
local size = 2^13 -- good buffer size (8K)
|
||||
while bRun do
|
||||
local sReadLine = io.stdin:read( 'l')
|
||||
EgtOutLog( 'Letta riga da stdin')
|
||||
if sReadLine then
|
||||
if sReadLine == 'quit' then
|
||||
EgtOutLog( 'Chiusura processo')
|
||||
break
|
||||
end
|
||||
if sReadLine ~= '' and sReadLine:find( '^#8477271#') and sReadLine:find( '#8477271#$') then
|
||||
EgtOutLog( 'Lettura istruzione valida')
|
||||
sReadLine = string.sub( sReadLine, 10, #sReadLine - 9)
|
||||
local Question = JSON:decode( sReadLine)
|
||||
local nThreadIndex = -1
|
||||
local nId = -1
|
||||
local ExecEnvironment = -1
|
||||
local nResult = 0
|
||||
local AnswerArgs = {}
|
||||
if Question and Question.nThreadIndex and Question.nId and Question.Args then
|
||||
nThreadIndex = tonumber( Question["nThreadIndex"])
|
||||
nId = tonumber( Question["nId"])
|
||||
ExecEnvironment = tonumber( Question["ExecEnvironment"])
|
||||
local QuestionArgs = Question["Args"]
|
||||
if QuestionArgs and QuestionArgs.UID and QuestionArgs.Mode and QuestionArgs.SubMode then
|
||||
local sUid = QuestionArgs["UID"]
|
||||
local nMode = tonumber( QuestionArgs["Mode"])
|
||||
-- esecuzione della corretta modalita'
|
||||
EgtOutLog('Esecuzione calcolo')
|
||||
--if nMode == QUESTION_MODES.PREVIEW then
|
||||
-- nResult, AnswerArgs = Calc_Preview( QuestionArgs)
|
||||
--elseif nMode == QUESTION_MODES.BOM then
|
||||
-- nResult, AnswerArgs = Calc_BOM( QuestionArgs)
|
||||
if nMode == QUESTION_MODES.HARDWARE then
|
||||
if QuestionArgs.SubMode and QuestionArgs.Manufacturer then
|
||||
local nSubMode = tonumber( QuestionArgs["SubMode"])
|
||||
local nManufacturer = tonumber( QuestionArgs["Manufacturer"])
|
||||
if nSubMode == QUESTION_HARDWARE_SUBMODES.LIST then
|
||||
nResult, AnswerArgs = Calc_HardwareModelList( nManufacturer)
|
||||
if AnswerArgs then
|
||||
AnswerArgs.OutputChannel = QuestionArgs["OutputChannel"]
|
||||
end
|
||||
elseif nSubMode == QUESTION_HARDWARE_SUBMODES.CALCHARDWARE then
|
||||
nResult, AnswerArgs = Calc_WindowHardware( nManufacturer, QuestionArgs)
|
||||
if AnswerArgs then
|
||||
AnswerArgs.OutputChannel = QuestionArgs["OutputChannel"]
|
||||
end
|
||||
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 o Manufacturer che sono obbligatori!'
|
||||
AnswerArgs = { Error = sErrorMsg}
|
||||
EgtOutLog( sErrorMsg)
|
||||
end
|
||||
end
|
||||
AnswerArgs.UID = sUid
|
||||
else
|
||||
nResult = 0
|
||||
local sErrorMsg = 'Errore! Domanda senza argomenti, senza UID o Mode che sono obbligatori!'
|
||||
AnswerArgs = { Error = sErrorMsg}
|
||||
EgtOutLog( sErrorMsg)
|
||||
end
|
||||
else
|
||||
nResult = 0
|
||||
local sErrorMsg = 'Errore! Formato domanda non riconosciuto o senza nThreadIndex, nId o Args!'
|
||||
AnswerArgs = { Error = sErrorMsg}
|
||||
EgtOutLog( sErrorMsg)
|
||||
end
|
||||
-- do risultato
|
||||
local Result = { nThreadIndex = nThreadIndex,
|
||||
nId = nId,
|
||||
ExecEnvironment = ExecEnvironment,
|
||||
nResult = nResult,
|
||||
Args = AnswerArgs}
|
||||
-- invio risposta
|
||||
EgtOutLog( 'Invio risposta')
|
||||
local JsonResult = JSON:encode( Result)
|
||||
io.stdout:write( "#8376261#" .. JsonResult .. "#8376261#" .. '\n')
|
||||
io.stdout:flush()
|
||||
EgtOutLog( 'Risposta inviata')
|
||||
EgtNewFile()
|
||||
end
|
||||
else
|
||||
if nNilCount >= 20 then
|
||||
bRun = false
|
||||
EgtOutLog( 'Errore! Lettura da stdin fallita!')
|
||||
end
|
||||
nNilCount = nNilCount + 1
|
||||
EgtPause( 100, true)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user