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>
52 #include "nlsop_general.h"
54 #define LOGFILE "~/.nlsop_logfile"
59 printf("%s -i <ip> -p <port> -l <logfile>\n",prog);
64 * gui internal functions
67 int display_new_line(t_display *display,char *text) {
78 tmp=(unsigned char *)malloc(display->max_x);
79 memset(tmp,0x20,display->max_x);
81 display_line(display,0,0,x,0,'#');
82 display_string(display,1,y-y/2-17,"nlsop gui (C) 2004 Frank Zirkelbach",35);
83 display_line(display,0,2,x,2,'#');
84 display_line(display,0,y-1,x,y-1,'#');
85 display_string(display,0,y,"prompt: ",8);
86 display_string(display,8,y,tmp,x-8);
87 display_set_cursor(display,8,y);
90 for(i=0;i<display->max_x-6;i++) {
91 memcpy(display->screen+ptr,display->screen+ptr+display->max_x,
96 display_draw(display);
101 int send_and_wait_for_answer(t_net *net,t_display *display) {
106 char string[MAX_CONTENT];
110 /* request information */
111 network_send_chan(net,0,&data,sizeof(unsigned char));
113 /* receive information */
114 network_receive_chan(net,0,&data,sizeof(unsigned char));
116 display_new_line(display,"no gui info answer, ignored");
120 network_receive_chan(net,0,(unsigned char *)&count,sizeof(int));
121 for(i=0;i<count;i++) {
122 network_receive_chan(net,0,(unsigned char *)&job,sizeof(t_job));
123 snprintf(string,MAX_CONTENT,
124 "channel %d %c => b=%f c=%f s=%f | d: %d %f | %d",
125 job.channel,job.status&IN_WORK?'a':'q',
126 job.info.b,job.info.c,job.info.s,
127 job.info.diff_rate,job.info.dr_ac,job.progress);
128 display_new_line(display,string);
131 display_new_line(display,"done");
136 int send_job(t_net *net,t_input *input,t_display *display) {
138 char command[MAX_CONTENT];
149 info.diff_rate=DIFF_RATE;
152 info.save_rate=RESAVE;
158 strncpy(command,input->content,MAX_CONTENT);
161 while(strtok(NULL," ")!=NULL) {
164 info.b=atof(command+1);
167 info.c=atof(command+1);
170 info.s=atof(command+1);
173 info.diff_rate=atoi(command+1);
176 info.dr_ac=atof(command+1);
179 info.steps=atoi(command+1);
182 info.cpi=atoi(command+1);
185 info.range=atoi(command+1);
188 info.s_rate=atoi(command+1);
191 info.save_rate=atoi(command+1);
203 display_new_line(display,"unknown command");
208 command[0]=GUI_ADDJOB;
209 network_send_chan(net,0,command,1);
211 network_send_chan(net,0,(unsigned char *)&x,sizeof(int));
212 network_send_chan(net,0,(unsigned char *)&y,sizeof(int));
213 network_send_chan(net,0,(unsigned char *)&z,sizeof(int));
215 network_send_chan(net,0,(unsigned char *)&info,sizeof(info));
220 int get_command(t_event *event,void *allineed) {
225 unsigned int addr[3];
227 memcpy(addr,allineed,3*sizeof(unsigned int));
228 net=(t_net *)addr[0];
229 display=(t_display *)addr[1];
230 input=(t_input *)addr[2];
232 switch(input->content[0]) {
234 send_and_wait_for_answer(net,display);
237 send_job(net,input,display);
240 /* stop everything */
241 event_math(0,event,READ,REMOVE);
242 network_shutdown(net);
243 display_shutdown(display);
244 input_shutdown(input);
248 display_new_line(display,"unknown gui command");
259 int main(int argc,char **argv)
276 unsigned int addr[3];
279 allyouneed=(void *)addr;
281 addr[0]=(unsigned int)&net;
282 addr[1]=(unsigned int)&display;
283 addr[2]=(unsigned int)&input;
286 strcpy(logfile,LOGFILE);
287 strcpy(server_ip,"");
290 /* parse/check argv */
291 for(i=1;i<argc;i++) {
292 if(argv[i][0]=='-') {
298 strncpy(server_ip,argv[++i],16);
301 port=atoi(argv[++i]);
304 strncpy(logfile,argv[++i],64);
312 if(!strcmp(server_ip,"")) {
317 if((fd=open(logfile,O_WRONLY|O_CREAT))<0) {
318 printf("unable to open file %s\n",logfile);
323 input_init(&input,fd);
324 input.mode=CONTENT_BUFFER|LINE_BUFFERED|INPUT_ECHO;
325 input_ios_init(&input);
328 event_init(&event,fd);
329 event_set_timeout(&event,0,0);
332 display_init(&display,fd);
334 /* user interaction */
335 event_math(0,&event,READ,ADD);
337 display_new_line(&display,"welcome to nlsop gui! :)");
339 /* connect to server */
340 network_init(&net,fd);
341 network_set_connection_info(&net,0,server_ip,port);
342 if(network_connect(&net,0)==N_E_CONNECT) {
343 printf("unable to connect to server, aborting ...\n");
346 network_select(&net,0);
348 display_new_line(&display,"successfully connected to server");
350 /* tell server: i am a client, i may work for you */
352 network_send(net.connection[0].fd,&data,1);
354 display_new_line(&display,"send data to server, waiting for input ...");
357 event_start(&event,allyouneed,get_command,NULL);