| 2258 | } |
| 2259 | |
| 2260 | bool CEventSystem::parseBlocklyActions(const _tEventItem &item) |
| 2261 | { |
| 2262 | if (isEventscheduled(item.Name)) |
| 2263 | { |
| 2264 | return false; |
| 2265 | } |
| 2266 | bool actionsDone = false; |
| 2267 | std::string csubstr; |
| 2268 | std::string tmpstr(item.Actions); |
| 2269 | size_t sPos = 0, ePos; |
| 2270 | do |
| 2271 | { |
| 2272 | ePos = tmpstr.find(",commandArray["); |
| 2273 | if (ePos != std::string::npos) |
| 2274 | { |
| 2275 | csubstr = tmpstr.substr(0, ePos); |
| 2276 | tmpstr = tmpstr.substr(ePos + 1); |
| 2277 | } |
| 2278 | else |
| 2279 | { |
| 2280 | csubstr = tmpstr; |
| 2281 | tmpstr.clear(); |
| 2282 | } |
| 2283 | sPos = csubstr.find_first_of('['); |
| 2284 | ePos = csubstr.find_first_of(']'); |
| 2285 | |
| 2286 | if ((sPos == std::string::npos) || (ePos == std::string::npos)) |
| 2287 | { |
| 2288 | _log.Log(LOG_ERROR, "EventSystem: Malformed action sequence!"); |
| 2289 | break; |
| 2290 | } |
| 2291 | |
| 2292 | size_t eQPos = csubstr.find_first_of('='); |
| 2293 | if (eQPos == std::string::npos) { |
| 2294 | _log.Log(LOG_ERROR, "EventSystem: Malformed action sequence!"); |
| 2295 | break; |
| 2296 | } |
| 2297 | std::string doWhat = csubstr.substr(eQPos + 1); |
| 2298 | StripQuotes(doWhat); |
| 2299 | |
| 2300 | std::string deviceName = csubstr.substr(sPos + 1, ePos - sPos - 1); |
| 2301 | if (deviceName.empty()) |
| 2302 | { |
| 2303 | _log.Log(LOG_ERROR, "EventSystem: Malformed action sequence!"); |
| 2304 | break; |
| 2305 | } |
| 2306 | |
| 2307 | int deviceNo = atoi(deviceName.c_str()); |
| 2308 | if (deviceNo) |
| 2309 | { |
| 2310 | boost::shared_lock<boost::shared_mutex> devicestatesMutexLock(m_devicestatesMutex); |
| 2311 | if (m_devicestates.count(deviceNo)) { |
| 2312 | devicestatesMutexLock.unlock(); // Unlock to avoid recursive lock (because the ScheduleEvent function locks again) |
| 2313 | if (ScheduleEvent(deviceNo, doWhat, false, item.Name, 0)) { |
| 2314 | actionsDone = true; |
| 2315 | } |
| 2316 | } |
| 2317 | else { |
nothing calls this directly
no test coverage detected