1 /***************************************************************************
3 * Copyright 2012 BMW Car IT GmbH
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either inputess or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 ****************************************************************************/
19 #include "ilm_client.h"
20 #include "LMControl.h"
21 #include "Expression.h"
22 #include "ExpressionInterpreter.h"
31 #include <signal.h> // signal
32 #include <unistd.h> // alarm
37 #define COMMAND(text) COMMAND2(__COUNTER__,text)
39 #define COMMAND2(x,y) COMMAND3(x,y)
41 #define COMMAND3(funcNumber, text) \
42 void func_ ## funcNumber(Expression* input); \
43 static const bool reg_ ## funcNumber = \
44 ExpressionInterpreter::addExpression(func_ ## funcNumber, text); \
45 void func_ ## funcNumber(Expression* input)
49 //=============================================================================
51 //=============================================================================
54 cout << "help: supported commands:\n\n";
55 ExpressionInterpreter::printExpressionList();
59 //=============================================================================
61 //=============================================================================
64 cout << "help: supported commands:\n\n";
65 ExpressionInterpreter::printExpressionTree();
69 //=============================================================================
70 COMMAND("get screens")
71 //=============================================================================
74 unsigned int count = 0;
75 unsigned int* array = NULL;
76 ilm_getScreenIDs(&count, &array);
77 printArray("Screen", array, count);
80 //=============================================================================
82 //=============================================================================
86 unsigned int* array = NULL;
87 ilm_getLayerIDs(&count, &array);
88 printArray("Layer", array, count);
91 //=============================================================================
92 COMMAND("get surfaces")
93 //=============================================================================
97 unsigned int* array = NULL;
98 ilm_getSurfaceIDs(&count, &array);
99 printArray("Surface", array, count);
102 //=============================================================================
103 COMMAND("get screen <screenid>")
104 //=============================================================================
106 printScreenProperties(input->getUint("screenid"));
109 //=============================================================================
110 COMMAND("get layer <layerid>")
111 //=============================================================================
113 printLayerProperties(input->getUint("layerid"));
116 //=============================================================================
117 COMMAND("get surface <surfaceid>")
118 //=============================================================================
120 printSurfaceProperties(input->getUint("surfaceid"));
123 //=============================================================================
124 COMMAND("dump screen <screenid> to <file>")
125 //=============================================================================
127 ilm_takeScreenshot(input->getUint("screenid"),
128 input->getString("file").c_str());
131 //=============================================================================
132 COMMAND("dump layer <layerid> to <file>")
133 //=============================================================================
135 ilm_takeLayerScreenshot(input->getString("file").c_str(),
136 input->getUint("layerid"));
139 //=============================================================================
140 COMMAND("dump surface <surfaceid> to <file>")
141 //=============================================================================
143 ilm_takeSurfaceScreenshot(input->getString("file").c_str(),
144 input->getUint("surfaceid"));
147 //=============================================================================
148 COMMAND("set layer <layerid> source region <x> <y> <w> <h>")
149 //=============================================================================
151 ilm_layerSetSourceRectangle(input->getUint("layerid"),
155 input->getUint("h"));
159 //=============================================================================
160 COMMAND("set surface <surfaceid> source region <x> <y> <w> <h>")
161 //=============================================================================
163 ilm_surfaceSetSourceRectangle(input->getUint("surfaceid"),
167 input->getUint("h"));
171 //=============================================================================
172 COMMAND("set layer <layerid> destination region <x> <y> <w> <h>")
173 //=============================================================================
175 ilm_layerSetDestinationRectangle(input->getUint("layerid"),
179 input->getUint("h"));
183 //=============================================================================
184 COMMAND("set surface <surfaceid> destination region <x> <y> <w> <h>")
185 //=============================================================================
187 ilm_surfaceSetDestinationRectangle(input->getUint("surfaceid"),
191 input->getUint("h"));
195 //=============================================================================
196 COMMAND("set layer <layerid> opacity <opacity>")
197 //=============================================================================
199 ilm_layerSetOpacity(input->getUint("layerid"),
200 input->getDouble("opacity"));
204 //=============================================================================
205 COMMAND("set surface <surfaceid> opacity <opacity>")
206 //=============================================================================
208 ilm_surfaceSetOpacity(input->getUint("surfaceid"),
209 input->getDouble("opacity"));
213 //=============================================================================
214 COMMAND("set layer <layerid> visibility <visibility>")
215 //=============================================================================
217 ilm_layerSetVisibility(input->getUint("layerid"),
218 input->getBool("visibility"));
222 //=============================================================================
223 COMMAND("set surface <surfaceid> visibility <visibility>")
224 //=============================================================================
226 ilm_surfaceSetVisibility(input->getUint("surfaceid"),
227 input->getBool("visibility"));
231 //=============================================================================
232 COMMAND("set layer <layerid> orientation <orientation>")
233 //=============================================================================
235 ilm_layerSetOrientation(input->getUint("layerid"),
236 (ilmOrientation)input->getInt("orientation"));
240 //=============================================================================
241 COMMAND("set surface <surfaceid> orientation <orientation>")
242 //=============================================================================
244 ilm_surfaceSetOrientation(input->getUint("surfaceid"),
245 (ilmOrientation)input->getInt("orientation"));
249 //=============================================================================
250 COMMAND("set screen <screenid> render order <layeridarray>")
251 //=============================================================================
253 unsigned int count = 0;
254 unsigned int* array = NULL;
255 unsigned int screenid = input->getUint("screenid");
256 input->getUintArray("layeridarray", &array, &count);
257 ilm_displaySetRenderOrder(screenid, array, count);
261 //=============================================================================
262 COMMAND("set screen <screenid> render order")
263 //=============================================================================
265 unsigned int screenid = input->getUint("screenid");
266 ilm_displaySetRenderOrder(screenid, NULL, 0);
270 //=============================================================================
271 COMMAND("set layer <layerid> render order <surfaceidarray>")
272 //=============================================================================
274 unsigned int count = 0;
275 unsigned int* array = NULL;
276 unsigned int layerid = input->getUint("layerid");
277 input->getUintArray("surfaceidarray", &array, &count);
278 ilm_layerSetRenderOrder(layerid, array, count);
282 //=============================================================================
283 COMMAND("set layer <layerid> render order")
284 //=============================================================================
286 unsigned int layerid = input->getUint("layerid");
287 ilm_layerSetRenderOrder(layerid, NULL, 0);
291 //=============================================================================
292 COMMAND("set layer <layerid> width <width>")
293 //=============================================================================
295 unsigned int dimension[2];
296 unsigned int layerid = input->getUint("layerid");
297 ilm_layerGetDimension(layerid, dimension);
298 dimension[0] = input->getUint("width");
299 ilm_layerSetDimension(layerid, dimension);
303 //=============================================================================
304 COMMAND("set surface <surfaceid> width <width>")
305 //=============================================================================
307 unsigned int dimension[2];
308 unsigned int surfaceid = input->getUint("surfaceid");
309 ilm_surfaceGetDimension(surfaceid, dimension);
310 dimension[0] = input->getUint("width");
311 ilm_surfaceSetDimension(surfaceid, dimension);
315 //=============================================================================
316 COMMAND("set layer <layerid> height <height>")
317 //=============================================================================
319 unsigned int dimension[2];
320 unsigned int layerid = input->getUint("layerid");
321 ilm_layerGetDimension(layerid, dimension);
322 dimension[1] = input->getUint("height");
323 ilm_layerSetDimension(layerid, dimension);
327 //=============================================================================
328 COMMAND("set surface <surfaceid> height <height>")
329 //=============================================================================
331 unsigned int dimension[2];
332 unsigned int surfaceid = input->getUint("surfaceid");
333 ilm_surfaceGetDimension(surfaceid, dimension);
334 dimension[1] = input->getUint("height");
335 ilm_surfaceSetDimension(surfaceid, dimension);
339 //=============================================================================
340 COMMAND("set layer <layerid> position <x> <y>")
341 //=============================================================================
343 unsigned int dimension[2];
344 unsigned int layerid = input->getUint("layerid");
345 dimension[0] = input->getUint("x");
346 dimension[1] = input->getUint("y");
347 ilm_layerSetPosition(layerid, dimension);
351 //=============================================================================
352 COMMAND("set surface <surfaceid> position <x> <y>")
353 //=============================================================================
355 unsigned int dimension[2];
356 unsigned int surfaceid = input->getUint("surfaceid");
357 dimension[0] = input->getUint("x");
358 dimension[1] = input->getUint("y");
359 ilm_surfaceSetPosition(surfaceid, dimension);
363 //=============================================================================
364 COMMAND("create layer <layerid>")
365 //=============================================================================
367 unsigned int layerid = input->getUint("layerid");
368 ilm_layerCreate(&layerid);
371 //=============================================================================
372 COMMAND("create layer <layerid> <width> <height>")
373 //=============================================================================
375 unsigned int layerid = input->getUint("layerid");
376 unsigned int width = input->getUint("width");
377 unsigned int height = input->getUint("height");
378 ilm_layerCreateWithDimension(&layerid, width, height);
381 //=============================================================================
382 COMMAND("create surface <surfaceid> <nativehandle> <width> <height> <pixelformat>")
383 //=============================================================================
385 unsigned int surfaceid = input->getUint("surfaceid");
386 unsigned int nativeHandle = input->getUint("nativehandle");
387 unsigned int width = input->getUint("width");
388 unsigned int height = input->getUint("height");
389 e_ilmPixelFormat pixelformat = (e_ilmPixelFormat)input->getUint("pixelformat");
390 ilm_surfaceCreate(nativeHandle, width, height, pixelformat, &surfaceid);
393 //=============================================================================
394 COMMAND("destroy layer <layerid>")
395 //=============================================================================
397 unsigned int layerid = input->getUint("layerid");
398 ilm_layerRemove(layerid);
401 //=============================================================================
402 COMMAND("destroy surface <surfaceid>")
403 //=============================================================================
405 unsigned int surfaceid = input->getUint("surfaceid");
406 ilm_surfaceRemove(surfaceid);
409 //=============================================================================
411 //=============================================================================
416 //=============================================================================
417 COMMAND("get communicator performance")
418 //=============================================================================
420 getCommunicatorPerformance();
423 //=============================================================================
424 COMMAND("set surface <surfaceid> keyboard focus")
425 //=============================================================================
427 t_ilm_surface surface = input->getUint("surfaceid");
429 setSurfaceKeyboardFocus(surface);
432 //=============================================================================
433 COMMAND("get keyboard focus")
434 //=============================================================================
439 //=============================================================================
440 COMMAND("set surface <surfaceid> accept <acceptance> input events from devices <kbd:pointer:touch>")
441 //=============================================================================
443 t_ilm_surface surfaceId = input->getUint("surfaceid");
444 t_ilm_bool acceptance = input->getBool("acceptance");
445 string kbdPointerTouch = input->getString("kbd:pointer:touch");
447 setSurfaceAcceptsInput(surfaceId, kbdPointerTouch, acceptance);
450 //=============================================================================
451 COMMAND("set surface <surfaceid> chromakey <red> <green> <blue>")
452 //=============================================================================
454 t_ilm_surface surface = input->getUint("surfaceid");
457 input->getInt("red"),
458 input->getInt("green"),
459 input->getInt("blue")
461 ilm_surfaceSetChromaKey(surface, color);
465 //=============================================================================
466 COMMAND("set surface <surfaceid> chromakey disabled")
467 //=============================================================================
469 t_ilm_surface surface = input->getUint("surfaceid");
470 ilm_surfaceSetChromaKey(surface, NULL);
474 //=============================================================================
475 COMMAND("set layer <layerid> chromakey <red> <green> <blue>")
476 //=============================================================================
478 t_ilm_surface surface = input->getUint("layerid");
481 input->getInt("red"),
482 input->getInt("green"),
483 input->getInt("blue")
486 ilm_layerSetChromaKey(surface, color);
490 //=============================================================================
491 COMMAND("test notification layer <layerid>")
492 //=============================================================================
494 unsigned int layerid = input->getUint("layerid");
496 testNotificationLayer(layerid);
499 //=============================================================================
500 COMMAND("watch layer <layeridarray>")
501 //=============================================================================
503 unsigned int* layerids = NULL;
504 unsigned int layeridCount;
505 input->getUintArray("layeridarray", &layerids, &layeridCount);
507 watchLayer(layerids, layeridCount);
510 //=============================================================================
511 COMMAND("watch surface <surfaceidarray>")
512 //=============================================================================
514 unsigned int* surfaceids = NULL;
515 unsigned int surfaceidCount;
516 input->getUintArray("surfaceidarray", &surfaceids, &surfaceidCount);
518 watchSurface(surfaceids, surfaceidCount);
521 //=============================================================================
522 COMMAND("set optimization <id> mode <mode>")
523 //=============================================================================
525 t_ilm_uint id = input->getUint("id");
526 t_ilm_uint mode = input->getUint("mode");
527 setOptimization(id, mode);
530 //=============================================================================
531 COMMAND("get optimization <id>")
532 //=============================================================================
534 t_ilm_uint id = input->getUint("id");
538 //=============================================================================
539 COMMAND("analyze surface <surfaceid>")
540 //=============================================================================
542 t_ilm_surface targetSurfaceId = (t_ilm_uint) input->getUint("surfaceid");
543 analyzeSurface(targetSurfaceId);
546 //=============================================================================
548 //=============================================================================
553 //=============================================================================
554 COMMAND("scatter all")
555 //=============================================================================
560 //=============================================================================
561 COMMAND("demo <animation_mode>")
562 //=============================================================================
564 int mode = (int) input->getInt("animation_mode");