|
115 | 115 | function parseXmlBlocks(xml,pairId) {
|
116 | 116 | var boolString = "";
|
117 | 117 |
|
118 |
| - function parseLogicCompare(thisBlock){ |
119 |
| - var locOperand = opSymbol($($(thisBlock).children("title:first")).text()); |
120 |
| - var valueA = $(thisBlock).children("value[name='A']")[0]; |
121 |
| - var variableType = $(valueA).children("block:first").attr("type"); |
122 |
| - |
| 118 | + function GetValueText(value, variableType) { |
123 | 119 | if (variableType.indexOf("switchvariables") >= 0) {
|
124 |
| - var titleA = $(valueA).find("title")[0]; |
125 |
| - var valueB = $(thisBlock).children("value[name='B']")[0]; |
126 |
| - var titleB = $(valueB).find("title")[0]; |
127 |
| - var compareString = "device["+$(titleA).text()+"]"; |
128 |
| - if ($(titleB).attr("name") == "State") { |
129 |
| - compareString += locOperand; |
130 |
| - compareString += '"'+$(titleB).text()+'"'; |
131 |
| - } |
132 |
| - return compareString; |
| 120 | + var titleA = $(value).find("title")[0]; |
| 121 | + return "device["+$(titleA).text()+"]"; |
133 | 122 | }
|
134 |
| - if (variableType.indexOf("uservariables") >= 0) { |
135 |
| - var compareString = ""; |
| 123 | + else if (variableType.indexOf("uservariables") >= 0) { |
136 | 124 | var titleA = $(valueA).find("title")[0];
|
137 |
| - var valueB = $(thisBlock).children("value[name='B']")[0]; |
138 |
| - var titleB = $(valueB).find("title")[0]; |
139 |
| - if ($(titleB).attr("name") == "TEXT") { |
140 |
| - compareString = "variable["+$(titleA).text()+"]"; |
141 |
| - compareString += locOperand; |
142 |
| - compareString += '"'+encodeURIComponent($(titleB).text())+'"'; |
143 |
| - } |
144 |
| - else if ($(titleB).attr("name") == "NUM") { |
145 |
| - compareString = "variable["+$(titleA).text()+"]"; |
146 |
| - compareString += locOperand; |
147 |
| - compareString += $(titleB).text(); |
148 |
| - } |
149 |
| - return compareString; |
| 125 | + return "variable["+$(titleA).text()+"]"; |
150 | 126 | }
|
151 | 127 | else if (variableType == "temperaturevariables") {
|
152 |
| - var titleA = $(valueA).find("title")[0]; |
153 |
| - var valueB = $(thisBlock).children("value[name='B']")[0]; |
154 |
| - var titleB = $(valueB).find("title")[0]; |
155 |
| - var compareString = "temperaturedevice["+$(titleA).text()+"]"; |
156 |
| - if ($(titleB).attr("name") == "NUM") { |
157 |
| - compareString += locOperand; |
158 |
| - compareString += $(titleB).text(); |
159 |
| - } |
160 |
| - return compareString; |
| 128 | + var titleA = $(value).find("title")[0]; |
| 129 | + return "temperaturedevice["+$(titleA).text()+"]"; |
161 | 130 | }
|
162 | 131 | else if (variableType == "humidityvariables") {
|
163 |
| - var titleA = $(valueA).find("title")[0]; |
164 |
| - var valueB = $(thisBlock).children("value[name='B']")[0]; |
165 |
| - var titleB = $(valueB).find("title")[0]; |
166 |
| - var compareString = "humiditydevice["+$(titleA).text()+"]"; |
167 |
| - if ($(titleB).attr("name") == "NUM") { |
168 |
| - compareString += locOperand; |
169 |
| - compareString += +$(titleB).text(); |
170 |
| - } |
171 |
| - return compareString; |
| 132 | + var titleA = $(value).find("title")[0]; |
| 133 | + return "humiditydevice["+$(titleA).text()+"]"; |
172 | 134 | }
|
173 | 135 | else if (variableType == "dewpointvariables") {
|
174 |
| - var titleA = $(valueA).find("title")[0]; |
175 |
| - var valueB = $(thisBlock).children("value[name='B']")[0]; |
176 |
| - var titleB = $(valueB).find("title")[0]; |
177 |
| - var compareString = "dewpointdevice["+$(titleA).text()+"]"; |
178 |
| - if ($(titleB).attr("name") == "NUM") { |
179 |
| - compareString += locOperand; |
180 |
| - compareString += $(titleB).text(); |
181 |
| - } |
182 |
| - return compareString; |
| 136 | + var titleA = $(value).find("title")[0]; |
| 137 | + return "dewpointdevice["+$(titleA).text()+"]"; |
183 | 138 | }
|
184 | 139 | else if (variableType == "barometervariables") {
|
185 |
| - var titleA = $(valueA).find("title")[0]; |
186 |
| - var valueB = $(thisBlock).children("value[name='B']")[0]; |
187 |
| - var titleB = $(valueB).find("title")[0]; |
188 |
| - var compareString = "barometerdevice["+$(titleA).text()+"]"; |
189 |
| - if ($(titleB).attr("name") == "NUM") { |
190 |
| - compareString += locOperand; |
191 |
| - compareString += $(titleB).text(); |
192 |
| - } |
193 |
| - return compareString; |
| 140 | + var titleA = $(value).find("title")[0]; |
| 141 | + return "barometerdevice["+$(titleA).text()+"]"; |
194 | 142 | }
|
195 | 143 | else if (variableType.indexOf("utilityvariables") >= 0) {
|
196 |
| - var titleA = $(valueA).find("title")[0]; |
197 |
| - var valueB = $(thisBlock).children("value[name='B']")[0]; |
198 |
| - var titleB = $(valueB).find("title")[0]; |
199 |
| - var compareString = "utilitydevice["+$(titleA).text()+"]"; |
200 |
| - if ($(titleB).attr("name") == "NUM") { |
201 |
| - compareString += locOperand; |
202 |
| - compareString += $(titleB).text(); |
203 |
| - } |
204 |
| - return compareString; |
| 144 | + var titleA = $(value).find("title")[0]; |
| 145 | + return "utilitydevice["+$(titleA).text()+"]"; |
205 | 146 | }
|
206 | 147 | else {
|
| 148 | + var titleB = $(value).find("title")[0]; |
| 149 | + if ($(titleB).attr("name") == "State") { |
| 150 | + return '"'+$(titleB).text()+'"'; |
| 151 | + } |
| 152 | + else if ($(titleB).attr("name") == "TEXT") { |
| 153 | + return '"'+encodeURIComponent($(titleB).text())+'"'; |
| 154 | + } |
| 155 | + else if ($(titleB).attr("name") == "NUM") { |
| 156 | + return $(titleB).text(); |
| 157 | + } |
207 | 158 | return "unknown comparevariable "+variableType;
|
208 | 159 | }
|
209 | 160 | }
|
| 161 | + |
| 162 | + function parseLogicCompare(thisBlock){ |
| 163 | + var locOperand = opSymbol($($(thisBlock).children("title:first")).text()); |
| 164 | + var valueA = $(thisBlock).children("value[name='A']")[0]; |
| 165 | + var variableTypeA = $(valueA).children("block:first").attr("type"); |
| 166 | + var valueB = $(thisBlock).children("value[name='B']")[0]; |
| 167 | + var variableTypeB = $(valueB).children("block:first").attr("type"); |
| 168 | + |
| 169 | + var varTextA=GetValueText(valueA,variableTypeA); |
| 170 | + var varTextB=GetValueText(valueB,variableTypeB); |
| 171 | + |
| 172 | + var compareString = varTextA; |
| 173 | + compareString += locOperand; |
| 174 | + compareString += varTextB; |
| 175 | + return compareString; |
| 176 | + } |
210 | 177 |
|
211 | 178 | function parseLogicTimeOfDay(thisBlock) {
|
212 | 179 | var compareString = "";
|
|
0 commit comments