Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- commandArray = {}
- if uservariablechanged['IVTData'] then
- ivtdata = uservariables["IVTData"]
- function split(str,sep)
- local array = {}
- local reg = string.format("([^%s]+)",sep)
- for mem in string.gmatch(str,reg) do
- table.insert(array, mem)
- end
- return array
- end
- -- A function in Lua similar to PHP's print_r, from http://luanet.net/lua/function/print_r
- function print_r ( t )
- local print_r_cache={}
- local function sub_print_r(t,indent)
- if (print_r_cache[tostring(t)]) then
- print(indent.."*"..tostring(t))
- else
- print_r_cache[tostring(t)]=true
- if (type(t)=="table") then
- for pos,val in pairs(t) do
- if (type(val)=="table") then
- print(indent.."["..pos.."] => "..tostring(t).." {")
- sub_print_r(val,indent..string.rep(" ",string.len(pos)+8))
- print(indent..string.rep(" ",string.len(pos)+6).."}")
- else
- print(indent.."["..pos.."] => "..tostring(val))
- end
- end
- else
- print(indent..tostring(t))
- end
- end
- end
- sub_print_r(t," ")
- end
- local array = split(ivtdata,";")
- lopnr = array[1]
- framled_GT1 = array[2]
- ute_GT2 = array[3]
- tappvarmvatten_GT3_1 = array[4]
- varmvatten_GT3_2 = array[5]
- varmevatten_GT3_3 = array[6]
- rumstemp_GT5 = array[7]
- hetgastemperatur_GT6 = array[8]
- externgivare_temp_GT3_4 = array[9]
- tryckvakt_avfrost_GP3 = array[10]
- tryckvakt_hogtryck_HP = array[11]
- tryckvakt_logtryck_LP = array[12]
- externgivare_semester = array[13]
- kompressor_drift = array[14]
- schunt_oppna_SV1 = array[15]
- schunt_stang_SV1 = array[16]
- cirkpump_P1 = array[17]
- pryl_18 = array[18]
- larm = array[19]
- pryl_20 = array[20]
- pryl_21 = array[21]
- pryl_22 = array[22]
- borvarde_framledning_GT3_1 = array[23]
- pryl_24 = array[24]
- pryl_25 = array[25]
- pryl_26 = array[26]
- pryl_27 = array[27]
- pryl_28 = array[28]
- pryl_29 = array[29]
- extra_varmvatten1 = array[30]
- extra_varmvatten2 = array[31]
- extra_varmvatten3 = array[32]
- pryl_33 = array[33]
- elpatron1 = array[34]
- pryl_35 = array[35]
- elpatron2 = array[36]
- pryl_37 = array[37]
- pi_temp = array[38]
- --print_r(array)
- commandArray[#commandArray+1] = {['UpdateDevice'] = 436 .. '|0|' .. hetgastemperatur_GT6/10}
- commandArray[#commandArray+1] = {['UpdateDevice'] = 437 .. '|0|' .. ute_GT2/10}
- commandArray[#commandArray+1] = {['UpdateDevice'] = 440 .. '|0|' .. tappvarmvatten_GT3_1/10}
- commandArray[#commandArray+1] = {['UpdateDevice'] = 441 .. '|0|' .. varmvatten_GT3_2/10}
- commandArray[#commandArray+1] = {['UpdateDevice'] = 442 .. '|0|' .. varmevatten_GT3_3/10}
- commandArray[#commandArray+1] = {['UpdateDevice'] = 443 .. '|0|' .. framled_GT1/10}
- commandArray[#commandArray+1] = {['UpdateDevice'] = 444 .. '|0|' .. pi_temp}
- commandArray[#commandArray+1] = {['UpdateDevice'] = 449 .. '|0|' .. lopnr}
- --commandArray[#commandArray+1] = {['UpdateDevice'] = 450 .. '|0|' .. ivtdata}
- commandArray[#commandArray+1] = {['UpdateDevice'] = 451 .. '|0|' .. borvarde_framledning_GT3_1/10}
- --commandArray[#commandArray+1] = {['Variable:IVTDataTimestamp'] = tostring(os.time())}
- if (kompressor_drift == '1' and otherdevices['VP kompressor'] == 'Off') then
- commandArray[#commandArray+1]={['VP kompressor']='On'}
- end
- if (kompressor_drift == '0' and otherdevices['VP kompressor'] == 'On') then
- commandArray[#commandArray+1]={['VP kompressor']='Off'}
- end
- if (larm == '0' and otherdevices['VP larm'] == 'On') then
- commandArray[#commandArray+1]={['VP larm']='Off'}
- end
- if (larm ~= '0' and otherdevices['VP larm'] == 'Off') then
- commandArray[#commandArray+1]={['VP larm']='On'}
- end
- if (cirkpump_P1 == '1' and otherdevices['VP cirkulationspump (P1)'] == 'Off') then
- commandArray[#commandArray+1]={['VP cirkulationspump (P1)']='On'}
- end
- if (cirkpump_P1 == '0' and otherdevices['VP cirkulationspump (P1)'] == 'On') then
- commandArray[#commandArray+1]={['VP cirkulationspump (P1)']='Off'}
- end
- if (schunt_oppna_SV1 == '1' and otherdevices['VP schunt öppnar (SV1)'] == 'Off') then
- commandArray[#commandArray+1]={['VP schunt öppnar (SV1)']='On'}
- end
- if (schunt_oppna_SV1 == '0' and otherdevices['VP schunt öppnar (SV1)'] == 'On') then
- commandArray[#commandArray+1]={['VP schunt öppnar (SV1)']='Off'}
- end
- if (schunt_stang_SV1 == '1' and otherdevices['VP schunt stänger (SV1)'] == 'Off') then
- commandArray[#commandArray+1]={['VP schunt stänger (SV1)']='On'}
- end
- if (schunt_stang_SV1 == '0' and otherdevices['VP schunt stänger (SV1)'] == 'On') then
- commandArray[#commandArray+1]={['VP schunt stänger (SV1)']='Off'}
- end
- if (tryckvakt_avfrost_GP3 == '1' and otherdevices['VP tryckvakt avfrostning (GP3)'] == 'Off') then
- commandArray[#commandArray+1]={['VP tryckvakt avfrostning (GP3)']='On'}
- end
- if (tryckvakt_avfrost_GP3 == '0' and otherdevices['VP tryckvakt avfrostning (GP3)'] == 'On') then
- commandArray[#commandArray+1]={['VP tryckvakt avfrostning (GP3)']='Off'}
- end
- if (tryckvakt_hogtryck_HP == '1' and otherdevices['VP tryckvakt högtryck (GP3)'] == 'Off') then
- commandArray[#commandArray+1]={['VP tryckvakt högtryck (GP3)']='On'}
- end
- if (tryckvakt_hogtryck_HP == '0' and otherdevices['VP tryckvakt högtryck (GP3)'] == 'On') then
- commandArray[#commandArray+1]={['VP tryckvakt högtryck (GP3)']='Off'}
- end
- if (tryckvakt_logtryck_LP == '1' and otherdevices['VP tryckvakt lågtryck (GP1)'] == 'Off') then
- commandArray[#commandArray+1]={['VP tryckvakt lågtryck (GP1)']='On'}
- end
- if (tryckvakt_logtryck_LP == '0' and otherdevices['VP tryckvakt lågtryck (GP1)'] == 'On') then
- commandArray[#commandArray+1]={['VP tryckvakt lågtryck (GP1)']='Off'}
- end
- if (elpatron1 ~= '0' and otherdevices['VP elpatron 1'] == 'Off') then
- commandArray[#commandArray+1]={['VP elpatron 1']='On'}
- end
- if (elpatron1 == '0' and otherdevices['VP elpatron 1'] == 'On') then
- commandArray[#commandArray+1]={['VP elpatron 1']='Off'}
- end
- if (elpatron2 ~= '0' and otherdevices['VP elpatron 2'] == 'Off') then
- commandArray[#commandArray+1]={['VP elpatron 2']='On'}
- end
- if (elpatron2 == '0' and otherdevices['VP elpatron 2'] == 'On') then
- commandArray[#commandArray+1]={['VP elpatron 2']='Off'}
- end
- end
- return commandArray
Add Comment
Please, Sign In to add comment