4 * author: frank zirkelbach (frank.zirkelbach@physik.uni-augsburg.de)
6 * this program tries helping to understand the amorphous depuration
7 * and recrystallization of SiCx while ion implantation at temperatures
8 * below 400 degree celsius.
9 * hopefully the program will simulate the stabilization of the
10 * selforganizing lamella structure in the observed behaviour.
13 * - J. K. N. Lindner. Habil.Schrift, Universitaet Augsburg.
14 * - Maik Haeberlen. Diplomarbeit, Universitaet Augsburg.
16 * Copyright (C) 2004 Frank Zirkelbach
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
38 #include <sys/types.h>
51 #include "nlsop_general.h"
53 #define LOGFILE "~/.nlsop_logfile"
58 printf("%s -i <ip> -p <port> -l <logfile>\n",prog);
63 * gui internal functions
66 int display_new_line(t_display *display,char *text) {
71 int send_and_wait_for_answer(t_net *net,t_display *display) {
76 int send_job(t_net *net,t_input *input,t_display *display) {
78 char command[MAX_CONTENT];
89 info.diff_rate=DIFF_RATE;
92 info.save_rate=RESAVE;
98 strncpy(command,input->content,MAX_CONTENT);
101 while(strtok(NULL," ")!=NULL) {
104 info.b=atof(command+1);
107 info.c=atof(command+1);
110 info.s=atof(command+1);
113 info.diff_rate=atoi(command+1);
116 info.dr_ac=atof(command+1);
119 info.steps=atoi(command+1);
122 info.cpi=atoi(command+1);
125 info.range=atoi(command+1);
128 info.s_rate=atoi(command+1);
131 info.save_rate=atoi(command+1);
143 display_new_line(display,"unknown command");
148 command[0]=GUI_ADDJOB;
149 network_send_chan(net,0,data,1);
151 network_send_chan(net,0,(unsigned char *)&x,sizeof(int));
152 network_send_chan(net,0,(unsigned char *)&y,sizeof(int));
153 network_send_chan(net,0,(unsigned char *)&z,sizeof(int));
155 network_send_chan(net,0,(unsigned char *)&info,sizeof(info));
160 int get_command(t_event *event,void *allineed) {
166 unsigned char data[64];
168 net=(t_net *)allineed;
169 display=(t_display *)(allineed+sizeof(t_net));
170 input=(t_input *)(allineed+sizeof(t_net)+sizeof(t_display));
172 switch(input->content[0]) {
174 send_and_wait_for_answer(net,display);
177 send_job(net,input,display)
180 /* stop everything */
181 event_math(0,event,READ,REMOVE);
182 network_shutdown(net);
183 display_shutdown(display);
184 input_shutdown(input);
185 event_shutdown(event);
188 display_new_line(display,"unknown gui command");
199 int main(int argc,char **argv)
219 strcpy(logfile,LOGFILE);
220 strcpy(server_ip,"");
223 /* parse/check argv */
224 for(i=1;i<argc;i++) {
225 if(argv[i][0]=='-') {
231 strncpy(server_ip,argv[++i],16);
234 port=atoi(argv[++i]);
237 strncpy(logfile,argv[++i],64);
245 if(!strcmp(server_ip,"")) {
250 if((fd=open(logfile,O_WRONLY,O_CREAT))<0) {
251 printf("unable to open file %s\n",logfile);
255 allyouneed=malloc(sizeof(t_net)+sizeof(t_display)+sizeof(t_input));
256 memcpy(allyouneed,&net,sizeof(t_net));
257 memcpy(allyouneed+sizeof(t_net),&display,sizeof(t_display));
258 memcpy(allyouneed+sizeof(t_net)+sizeof(t_display),sizeof(t_input));
261 input_init(&input,fd);
262 input.mode=CONTENT_BUFFER|LINE_BUFFERED|INPUT_ECHO;
263 input_ios_init(&input);
266 event_init(&event,fd);
267 event_set_timeout(&event,0,0);
270 display_init(&display,fd);
272 /* user interaction */
273 event_math(0,&event,READ,ADD);
275 /* connect to server */
276 network_init(&net,fd);
277 network_set_connection_info(&net,0,server_ip,port);
278 if(network_connect(&net,0)==N_E_CONNECT) {
279 printf("unable to connect to server, aborting ...\n");
282 network_select(&net,0);
284 /* tell server: i am a client, i may work for you */
286 network_send(net.connection[0].fd,&data,1);
289 event_start(&event,allyouneed,get_command,NULL);