ElkM1API/ElkM1AsciiAPI.cpp
// TODO: Function to intelligently collect names: BUGGY! Doesn't work well over the Proxy.
// Should be somehow prioritized below regular send/rcv requests.

Function to intelligently collect names: BUGGY. Doesn't work well over the Proxy.
Should be somehow prioritized below regular send/rcv requests.
Function to intelligently collect names : BUGGY . Doesn ' t work well over the Proxy . Should be somehow prioritized below regular send / rcv requests .
void M1AsciiAPI::collectNames(TextDescriptionType type) {
		std::vector<int> indexes;
		cacheObject<std::string> *beginItr;
		cacheObject<std::string> *endItr;
		switch (type) {
		case TEXT_AreaName:
			indexes = getConfiguredAreas();
			beginItr = std::begin(m1cache.AreaNames);
			endItr = std::end(m1cache.AreaNames);
			break;
		case TEXT_ZoneName:
			indexes = getConfiguredZones();
			beginItr = std::begin(m1cache.ZoneNames);
			endItr = std::end(m1cache.ZoneNames);
			break;
		case TEXT_KeypadName:
			indexes = getConfiguredKeypads();
			beginItr = std::begin(m1cache.KeypadNames);
			endItr = std::end(m1cache.KeypadNames);
			break;
		case TEXT_OutputName:
			indexes = std::vector<int>(64);
			for (int i = 0; i < indexes.size(); i++)
				indexes[i] = i;
			beginItr = std::begin(m1cache.OutputNames);
			endItr = std::end(m1cache.OutputNames);
			break;
		default:
			throw std::runtime_error("Not imlemented.");
		}
		if (std::all_of(beginItr, endItr, [](cacheObject<std::string>& obj) {
			return obj.isInitialized();
		})) {
			return;
		}
		for (int index : indexes) {
			AsciiMessage message("sd");
			message += toAsciiDec(type, 2);
			message += toAsciiDec(index + 1, 3);
			message += "00";
			connection->Send(message.getTransmittable());
		}
		try {
			if (!beginItr[indexes.back()].isInitialized())
				beginItr[indexes.back()].awaitNew(std::chrono::milliseconds(1500));
		}
		catch (...)
		{
		}
		for (auto& block = beginItr; block != endItr; std::advance(block, 1)){
			if (!block->isInitialized())
				block->set("");
		}
	}
void M1AsciiAPI :: collectNames ( TextDescriptionType type ) { std :: vector < int > indexes ; cacheObject < std :: string > * beginItr ; cacheObject < std :: string > * endItr ; switch ( type ) { case TEXT_AreaName : indexes = getConfiguredAreas ( ) ; beginItr = std :: begin ( m1cache . AreaNames ) ; endItr = std :: end ( m1cache . AreaNames ) ; break ; case TEXT_ZoneName : indexes = getConfiguredZones ( ) ; beginItr = std :: begin ( m1cache . ZoneNames ) ; endItr = std :: end ( m1cache . ZoneNames ) ; break ; case TEXT_KeypadName : indexes = getConfiguredKeypads ( ) ; beginItr = std :: begin ( m1cache . KeypadNames ) ; endItr = std :: end ( m1cache . KeypadNames ) ; break ; case TEXT_OutputName : indexes = std :: vector < int > ( 64 ) ; for ( int i = 0 ; i < indexes . size ( ) ; i ++ ) indexes [ i ] = i ; beginItr = std :: begin ( m1cache . OutputNames ) ; endItr = std :: end ( m1cache . OutputNames ) ; break ; default : throw std :: runtime_error ( " " ) ; } if ( std :: all_of ( beginItr , endItr , [ ] ( cacheObject < std :: string > & obj ) { return obj . isInitialized ( ) ; } ) ) { return ; } for ( int index : indexes ) { AsciiMessage message ( " " ) ; message += toAsciiDec ( type , 2 ) ; message += toAsciiDec ( index + 1 , 3 ) ; message += " " ; connection -> Send ( message . getTransmittable ( ) ) ; } try { if ( ! beginItr [ indexes . back ( ) ] . isInitialized ( ) ) beginItr [ indexes . back ( ) ] . awaitNew ( std :: chrono :: milliseconds ( 1500 ) ) ; } catch ( ... ) { } for ( auto & block = beginItr ; block != endItr ; std :: advance ( block , 1 ) ) { if ( ! block -> isInitialized ( ) ) block -> set ( " " ) ; } }
TODO: Function to intelligently collect names: BUGGY!
TODO : Function to intelligently collect names : BUGGY!
// Request all area names 
 // Request all area names 
 // Request all area names 
 // If all are initialized, quit early
 // Timeout on the entire block
 // Fill untouched caches with blanks
