Skip to content

Commit f7141f1

Browse files
author
mcphatty
committed
section switch
1 parent 5f9b449 commit f7141f1

File tree

1 file changed

+74
-73
lines changed

1 file changed

+74
-73
lines changed

doc/user_manual/scripting/rtcommands/rtcommands.tex

Lines changed: 74 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -312,79 +312,6 @@ \subsection{Runtime Commands}
312312
% uidelay delay added after each injected ui event
313313
% value new value to set, content depending on the addressed ui element
314314

315-
\subsection{Python Example}
316-
317-
The following example will make use of the python class \textit{COMPASSInstance},
318-
which makes it quite easy to start a COMPASS instance, connect to it, send commands,
319-
and receive their reply data. \\
320-
321-
For readers interested in obtaining the python code for the COMPASSInstance class and
322-
more detailed example scripts, please contact us at \href{mailto:compass@openats.at}{compass@openats.at}. \\
323-
324-
Start a COMPASS instance and connect to it:
325-
326-
\begin{lstlisting}[basicstyle=\tiny\ttfamily]
327-
328-
from compass_interface import COMPASSInstance
329-
330-
import json
331-
332-
binary = 'home/user/path_to_binary'
333-
334-
compass_instance = COMPASSInstance()
335-
336-
ok, error = compass_instance.runCOMPASS(binary = binary,
337-
wait_for_commands = True, # wait until commands can be received
338-
no_cfg_save = True) # do not save config on close
339-
340-
# handle any errors
341-
342-
# ready to send commands!
343-
\end{lstlisting}
344-
345-
Sending commands:
346-
347-
\begin{lstlisting}[basicstyle=\tiny\ttfamily]
348-
349-
# open database
350-
filename = '/home/user/path_to_db_file'
351-
352-
# escape quotes for filename argument
353-
# the reply variable will hold the command's reply data as a python dictionary
354-
reply, ok, err = compass_instance.interface.sendCommandAndUnpack('open_db \"' + filename + '\"')
355-
356-
# handly any errors
357-
358-
# get result overview section of existing evaluation report
359-
report_name = 'test Evaluation'
360-
section = 'Report:Results:Overview:Results'
361-
362-
reply, ok, err = compass_instance.interface.sendCommandAndUnpack('get_report \"{}\" \"{}\"'.format(report_name, section))
363-
364-
# handle any errors
365-
366-
# the reply will contain the result overview section of the evaluated test standard as a json object
367-
# we can print it to view the reply result
368-
print('Retrieved section:\n')
369-
print(json.dumps(reply, indent = 4))
370-
371-
\end{lstlisting}
372-
373-
Close the COMPASS instance:
374-
375-
\begin{lstlisting}[basicstyle=\tiny\ttfamily]
376-
377-
compass_instance.closeCOMPASS()
378-
379-
\end{lstlisting}
380-
381-
As a result the script will output the retrieved result overview section of a pre-computed Evaluation report.
382-
383-
\begin{figure}[H]
384-
\hspace*{-2.5cm}
385-
\includegraphics[width=18cm,frame]{figures/script_result.png}
386-
\caption{Script output}
387-
\end{figure}
388315

389316
\subsection{Fetching Reports via get\_report}
390317
\label{sec:get_report}
@@ -458,3 +385,77 @@ \subsection{Fetching Reports via get\_report}
458385
]
459386
}
460387
\end{lstlisting}
388+
389+
\subsection{Python Example}
390+
391+
The following example will make use of the python class \textit{COMPASSInstance},
392+
which makes it quite easy to start a COMPASS instance, connect to it, send commands,
393+
and receive their reply data. \\
394+
395+
For readers interested in obtaining the python code for the COMPASSInstance class and
396+
more detailed example scripts, please contact us at \href{mailto:compass@openats.at}{compass@openats.at}. \\
397+
398+
Start a COMPASS instance and connect to it:
399+
400+
\begin{lstlisting}[basicstyle=\tiny\ttfamily]
401+
402+
from compass_interface import COMPASSInstance
403+
404+
import json
405+
406+
binary = 'home/user/path_to_binary'
407+
408+
compass_instance = COMPASSInstance()
409+
410+
ok, error = compass_instance.runCOMPASS(binary = binary,
411+
wait_for_commands = True, # wait until commands can be received
412+
no_cfg_save = True) # do not save config on close
413+
414+
# handle any errors
415+
416+
# ready to send commands!
417+
\end{lstlisting}
418+
419+
Sending commands:
420+
421+
\begin{lstlisting}[basicstyle=\tiny\ttfamily]
422+
423+
# open database
424+
filename = '/home/user/path_to_db_file'
425+
426+
# escape quotes for filename argument
427+
# the reply variable will hold the command's reply data as a python dictionary
428+
reply, ok, err = compass_instance.interface.sendCommandAndUnpack('open_db \"' + filename + '\"')
429+
430+
# handly any errors
431+
432+
# get result overview section of existing evaluation report
433+
report_name = 'test Evaluation'
434+
section = 'Report:Results:Overview:Results'
435+
436+
reply, ok, err = compass_instance.interface.sendCommandAndUnpack('get_report \"{}\" \"{}\"'.format(report_name, section))
437+
438+
# handle any errors
439+
440+
# the reply will contain the result overview section of the evaluated test standard as a json object
441+
# we can print it to view the reply result
442+
print('Retrieved section:\n')
443+
print(json.dumps(reply, indent = 4))
444+
445+
\end{lstlisting}
446+
447+
Close the COMPASS instance:
448+
449+
\begin{lstlisting}[basicstyle=\tiny\ttfamily]
450+
451+
compass_instance.closeCOMPASS()
452+
453+
\end{lstlisting}
454+
455+
As a result the script will output the retrieved result overview section of a pre-computed Evaluation report.
456+
457+
\begin{figure}[H]
458+
\hspace*{-2.5cm}
459+
\includegraphics[width=18cm,frame]{figures/script_result.png}
460+
\caption{Script output}
461+
\end{figure}

0 commit comments

Comments
 (0)