\section{guiserver.c File Reference}
\label{guiserver_8c}\index{guiserver.c@{guiserver.c}}
Server/User-Side Application with GUI to control the robot. 


{\tt \#include $<$time.h$>$}\par
{\tt \#include $<$math.h$>$}\par
{\tt \#include $<$pthread.h$>$}\par
{\tt \#include $<$stdio.h$>$}\par
{\tt \#include $<$stdlib.h$>$}\par
{\tt \#include $<$gtk/gtk.h$>$}\par
{\tt \#include $<$glib.h$>$}\par
{\tt \#include $<$unistd.h$>$}\par
{\tt \#include $<$signal.h$>$}\par
{\tt \#include \char`\"{}../lib/libcomm.h\char`\"{}}\par
{\tt \#include \char`\"{}guicommon.h\char`\"{}}\par
\subsection*{Functions}
\begin{CompactItemize}
\item 
void {\bf gs\_\-delete\_\-event} (Gtk\-Widget $\ast$widget, gpointer data)
\begin{CompactList}\small\item\em This function will be called be gtk when the window gets a closing command, it makes sure that the interface is down and the program is finished.\item\end{CompactList}\item 
void {\bf gs\_\-da\_\-expose\_\-event} (Gtk\-Widget $\ast$widget, gpointer data)
\begin{CompactList}\small\item\em This function is called by gtk if the drawing area (da) needs to be redrawn.\item\end{CompactList}\item 
void {\bf gs\_\-button\_\-press\_\-event} (Gtk\-Widget $\ast$widget, gpointer data)
\begin{CompactList}\small\item\em This function is called if a button is pressed.\item\end{CompactList}\item 
{\bf linemonitor\_\-exception} (char $\ast$server, int port, int type)
\begin{CompactList}\small\item\em Exception function for {\bf linemonitor\_\-server}() {\rm (p.\,\pageref{libcomm_8c_a17})}, print exception code and meaning on the screen and initiate appropriate actions if necessary.\item\end{CompactList}\item 
{\bf thread\_\-wait\_\-for\_\-linemonitor} ()
\begin{CompactList}\small\item\em Start the {\bf linemonitor\_\-server}() {\rm (p.\,\pageref{libcomm_8c_a17})} -- waiting for a connection in a background-thread.\item\end{CompactList}\item 
int {\bf main} (int argc, char $\ast$argv[$\,$])
\begin{CompactList}\small\item\em test0001sockts: see test0001sockts.c.\item\end{CompactList}\end{CompactItemize}
\subsection*{Variables}
\begin{CompactItemize}
\item 
Gtk\-Widget $\ast$ {\bf gs\_\-application}
\item 
int {\bf robot\_\-x} = 50
\item 
int {\bf robot\_\-y} = 0
\item 
{\bf ROBOT\_\-POSITION} {\bf robot\_\-position}
\item 
int {\bf serverport}
\item 
int {\bf sock}
\item 
int {\bf soft\_\-msec}
\item 
int {\bf hard\_\-msec}
\item 
int {\bf wait\_\-msec}
\item 
int {\bf ems\_\-fd}
\end{CompactItemize}


\subsection{Detailed Description}
Server/User-Side Application with GUI to control the robot.





\subsection{Function Documentation}
\index{guiserver.c@{guiserver.c}!gs_button_press_event@{gs\_\-button\_\-press\_\-event}}
\index{gs_button_press_event@{gs\_\-button\_\-press\_\-event}!guiserver.c@{guiserver.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void gs\_\-button\_\-press\_\-event (Gtk\-Widget $\ast$ {\em widget}, gpointer {\em data})}\label{guiserver_8c_a15}


This function is called if a button is pressed.

\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
widget}](Gtk\-Widget $\ast$) pointer to affected object (button).\item[{\em 
event}](Gdk\-Event\-Motion $\ast$) pointer to structure which describes the event. \end{description}
\end{Desc}
\index{guiserver.c@{guiserver.c}!gs_da_expose_event@{gs\_\-da\_\-expose\_\-event}}
\index{gs_da_expose_event@{gs\_\-da\_\-expose\_\-event}!guiserver.c@{guiserver.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void gs\_\-da\_\-expose\_\-event (Gtk\-Widget $\ast$ {\em widget}, gpointer {\em data})}\label{guiserver_8c_a13}


This function is called by gtk if the drawing area (da) needs to be redrawn.

For example if it becomes visible.\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
widget}](Gtk\-Widget $\ast$) pointer to affected object (in this case the drawing area).\item[{\em 
data}](gpointer) pointer to additional data from gtk. \end{description}
\end{Desc}
\index{guiserver.c@{guiserver.c}!gs_delete_event@{gs\_\-delete\_\-event}}
\index{gs_delete_event@{gs\_\-delete\_\-event}!guiserver.c@{guiserver.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void gs\_\-delete\_\-event (Gtk\-Widget $\ast$ {\em widget}, gpointer {\em data})}\label{guiserver_8c_a12}


This function will be called be gtk when the window gets a closing command, it makes sure that the interface is down and the program is finished.

\begin{Desc}
\item[Parameters: ]\par
\begin{description}
\item[{\em 
widget}](Gtk\-Widget $\ast$) pointer to affected object (for example: window).\item[{\em 
data}](gpointer) pointer to additional data from gtk. \end{description}
\end{Desc}
\index{guiserver.c@{guiserver.c}!linemonitor_exception@{linemonitor\_\-exception}}
\index{linemonitor_exception@{linemonitor\_\-exception}!guiserver.c@{guiserver.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}linemonitor\_\-exception (char $\ast$ {\em server}, int {\em port}, int {\em type})}\label{guiserver_8c_a16}


Exception function for {\bf linemonitor\_\-server}() {\rm (p.\,\pageref{libcomm_8c_a17})}, print exception code and meaning on the screen and initiate appropriate actions if necessary.

See {\bf linemonitor\_\-server}() {\rm (p.\,\pageref{libcomm_8c_a17})} API. \index{guiserver.c@{guiserver.c}!main@{main}}
\index{main@{main}!guiserver.c@{guiserver.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int main (int {\em argc}, char $\ast$ {\em argv}[$\,$])}\label{guiserver_8c_a18}


test0001sockts: see test0001sockts.c.

\index{guiserver.c@{guiserver.c}!thread_wait_for_linemonitor@{thread\_\-wait\_\-for\_\-linemonitor}}
\index{thread_wait_for_linemonitor@{thread\_\-wait\_\-for\_\-linemonitor}!guiserver.c@{guiserver.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}thread\_\-wait\_\-for\_\-linemonitor ()}\label{guiserver_8c_a17}


Start the {\bf linemonitor\_\-server}() {\rm (p.\,\pageref{libcomm_8c_a17})} -- waiting for a connection in a background-thread.

This has to be a thread because otherwise the system would block. It would wait for a connection while it is supposed to connect itself. 

\subsection{Variable Documentation}
\index{guiserver.c@{guiserver.c}!ems_fd@{ems\_\-fd}}
\index{ems_fd@{ems\_\-fd}!guiserver.c@{guiserver.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int ems\_\-fd}\label{guiserver_8c_a9}


\index{guiserver.c@{guiserver.c}!gs_application@{gs\_\-application}}
\index{gs_application@{gs\_\-application}!guiserver.c@{guiserver.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}Gtk\-Widget$\ast$ gs\_\-application}\label{guiserver_8c_a0}


\index{guiserver.c@{guiserver.c}!hard_msec@{hard\_\-msec}}
\index{hard_msec@{hard\_\-msec}!guiserver.c@{guiserver.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int hard\_\-msec}\label{guiserver_8c_a7}


\index{guiserver.c@{guiserver.c}!robot_position@{robot\_\-position}}
\index{robot_position@{robot\_\-position}!guiserver.c@{guiserver.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}struct {\bf ROBOT\_\-POSITION} robot\_\-position}\label{guiserver_8c_a3}


\index{guiserver.c@{guiserver.c}!robot_x@{robot\_\-x}}
\index{robot_x@{robot\_\-x}!guiserver.c@{guiserver.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int robot\_\-x = 50}\label{guiserver_8c_a1}


\index{guiserver.c@{guiserver.c}!robot_y@{robot\_\-y}}
\index{robot_y@{robot\_\-y}!guiserver.c@{guiserver.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int robot\_\-y = 0}\label{guiserver_8c_a2}


\index{guiserver.c@{guiserver.c}!serverport@{serverport}}
\index{serverport@{serverport}!guiserver.c@{guiserver.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int serverport}\label{guiserver_8c_a4}


\index{guiserver.c@{guiserver.c}!sock@{sock}}
\index{sock@{sock}!guiserver.c@{guiserver.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int sock}\label{guiserver_8c_a5}


\index{guiserver.c@{guiserver.c}!soft_msec@{soft\_\-msec}}
\index{soft_msec@{soft\_\-msec}!guiserver.c@{guiserver.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int soft\_\-msec}\label{guiserver_8c_a6}


\index{guiserver.c@{guiserver.c}!wait_msec@{wait\_\-msec}}
\index{wait_msec@{wait\_\-msec}!guiserver.c@{guiserver.c}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}int wait\_\-msec}\label{guiserver_8c_a8}


