Hi,
I'm trying to simplify some working code I have which connects girder to my heatmiser thermostats.
An extract is shown below (note, variables are declared elsewhere, this is just an extract and works fine, but is only part of a very long winded way of extracting bytes of data from a datastream and putting the values in a table)
I had hoped to loop through the various parts that make up the variable name (i.e. weekend/weekday/mon-sun etc.) then the time (1,2,3,4) and the data (hr, min, temp)Code:# Self.WeekdayTime1Hour = math.hextodecimal(table.concat(transport.devices.HeatmiserLink.HOUSE.TH,"",50,50))/1 Self.WeekdayTime1Minute = math.hextodecimal(table.concat(transport.devices.HeatmiserLink.HOUSE.TH,"",51,51))/1 Self.WeekdayTime1Temp = math.hextodecimal(table.concat(transport.devices.HeatmiserLink.HOUSE.TH,"",52,52))/1 Self.WeekdayTime2Hour = math.hextodecimal(table.concat(transport.devices.HeatmiserLink.HOUSE.TH,"",53,53))/1 Self.WeekdayTime2Minute = math.hextodecimal(table.concat(transport.devices.HeatmiserLink.HOUSE.TH,"",54,54))/1 Self.WeekdayTime2Temp = math.hextodecimal(table.concat(transport.devices.HeatmiserLink.HOUSE.TH,"",55,55))/1 Self.WeekdayTime3Hour = math.hextodecimal(table.concat(transport.devices.HeatmiserLink.HOUSE.TH,"",56,56))/1 Self.WeekdayTime3Minute = math.hextodecimal(table.concat(transport.devices.HeatmiserLink.HOUSE.TH,"",57,57))/1 Self.WeekdayTime3Temp = math.hextodecimal(table.concat(transport.devices.HeatmiserLink.HOUSE.TH,"",58,58))/1 Self.WeekdayTime4Hour = math.hextodecimal(table.concat(transport.devices.HeatmiserLink.HOUSE.TH,"",59,59))/1 Self.WeekdayTime4Minute = math.hextodecimal(table.concat(transport.devices.HeatmiserLink.HOUSE.TH,"",60,60))/1 Self.WeekdayTime4Temp = math.hextodecimal(table.concat(transport.devices.HeatmiserLink.HOUSE.TH,"",61,61))/1 Self.WeekendTime1Hour = math.hextodecimal(table.concat(transport.devices.HeatmiserLink.HOUSE.TH,"",62,62))/1 Self.WeekendTime1Minute = math.hextodecimal(table.concat(transport.devices.HeatmiserLink.HOUSE.TH,"",63,63))/1 Self.WeekendTime1Temp = math.hextodecimal(table.concat(transport.devices.HeatmiserLink.HOUSE.TH,"",64,64))/1 Self.WeekendTime2Hour = math.hextodecimal(table.concat(transport.devices.HeatmiserLink.HOUSE.TH,"",65,65))/1 Self.WeekendTime2Minute = math.hextodecimal(table.concat(transport.devices.HeatmiserLink.HOUSE.TH,"",66,66))/1 Self.WeekendTime2Temp = math.hextodecimal(table.concat(transport.devices.HeatmiserLink.HOUSE.TH,"",67,67))/1 Self.WeekendTime3Hour = math.hextodecimal(table.concat(transport.devices.HeatmiserLink.HOUSE.TH,"",68,68))/1 Self.WeekendTime3Minute = math.hextodecimal(table.concat(transport.devices.HeatmiserLink.HOUSE.TH,"",69,69))/1 Self.WeekendTime3Temp = math.hextodecimal(table.concat(transport.devices.HeatmiserLink.HOUSE.TH,"",70,70))/1 Self.WeekendTime4Hour = math.hextodecimal(table.concat(transport.devices.HeatmiserLink.HOUSE.TH,"",71,71))/1 Self.WeekendTime4Minute = math.hextodecimal(table.concat(transport.devices.HeatmiserLink.HOUSE.TH,"",72,72))/1 Self.WeekendTime4Temp = math.hextodecimal(table.concat(transport.devices.HeatmiserLink.HOUSE.TH,"",73,73))/1
I have done this successfully in netremote, so know the theory is right. (again, the code below is just an extract of the full file)
The issue is how to build up (concatenate?) the variable name before the =Code:Self.TheDay={ [1] = "Weekday", [2] = "Weekend", [3] = "Monday", [4] = "Tuesday", [5] = "Wednesday", [6] = "Thursday", [7] = "Friday", [8] = "Saturday", [9] = "Sunday" } Self.TimeGroup={ [1] = "1", [2] = "2", [3] = "3", [4] = "4" } Self.TheData={ [1] = "Hour", [2] = "Minute", [3] = "Temp" } ******************* Self.DSTIndex = 50 for s_TheDay = 1,2,1 do for s_TimeGroup = 1,4,1 do for s_TheData = 1,3,1 do Self.."."..(s_TheDay).."Time"..(s_TimeGroup)..(s_TheData) = math.hextodecimal(table.concat(transport.devices.HeatmiserLink.HOUSE.TH,"",Self.DSTIndex,Self.DSTIndex))/1 Self.DSTIndex = Self.DSTIndex + 1 end end end
The error I get is:
where line 336 is:Code:...ram Files\Promixis\Girder5\\luascript\compat-5.1.lua:93: error loading module `HOUSE.Thermostat' (C:\Program Files\Promixis\Girder5\luascript\HOUSE/Thermostat.lua:336: `=' expected near `..')
I'd appreciate anyone being able to advise how to do what I'm after.Code:Self.."."..(s_TheDay).."Time"..(s_TimeGroup)..(s_TheData) = math.hextodecimal(table.concat(transport.devices.HeatmiserLink.HOUSE.TH,"",Self.DSTIndex,Self.DSTIndex))/1
With thanks
Jon


Reply With Quote
