Beispiel #1
0
void Targets::processForm (XmlRpc::HttpParams *params, const char* &response_type, char* &response, size_t &response_length)
{
#ifdef RTS2_HAVE_LIBJPEG
	if (!strcmp (params->getString ("plot", "xxx"), "Plot target altitude"))
	{
		response_type = "image/jpeg";

		AltPlot ap (params->getInteger ("w", 800), params->getInteger ("h", 600));
		Magick::Geometry size (params->getInteger ("w", 800), params->getInteger ("h", 600));
	
		double from = params->getDouble ("from", 0);
		double to = params->getDouble ("to", 0);
	
		if (from < 0 && to == 0)
		{
			// just fr specified - from
			to = time (NULL);
			from += to;
		}
		else if (from == 0 && to == 0)
		{
			// default - one hour
			to = time (NULL);
			from = to - 86400;
		}


		std::list < int > ti;

		for (XmlRpc::HttpParams::iterator iter = params->begin (); iter != params->end (); iter++)
		{
			if (!strcmp (iter->getName (), "tid"))
				ti.push_back (atoi (iter->getValue ()));
		}

		rts2db::TargetSet ts = rts2db::TargetSet ();
		ts.load (ti);
	
		Magick::Image mimage (size, "white");
		ap.getPlot (from, to, &ts, &mimage);
	
		Magick::Blob blob;
		mimage.write (&blob, "jpeg");
	
		response_length = blob.length();
		response = new char[response_length];
		memcpy (response, blob.data(), response_length);
		return;
	}
#endif // RTS2_HAVE_LIBJPEG
}
Beispiel #2
0
AsyncValueAPI::AsyncValueAPI (JSONRequest *_req, XmlRpc::XmlRpcServerConnection *_source, XmlRpc::HttpParams *params): AsyncAPI (_req, NULL, _source, false) 
{
	// chunked response
	req->sendAsyncDataHeader (0, _source, "application/json");

	for (XmlRpc::HttpParams::iterator iter = params->begin (); iter != params->end (); iter++)
	{
	  	// handle special values - states,..
		if (strcmp (iter->getValue (), "__S__") == 0)
		{
			states.push_back (AsyncState (iter->getName ()));
		}
		else if (strcmp (iter->getValue (), "*") == 0)
		{
			states.push_back (AsyncState (iter->getName ()));
			devices.push_back (iter->getName ());
		}
		else
		{
			values.push_back (std::pair <std::string, std::string> (iter->getName (), iter->getValue ()));
		}
	}
}