Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/QNX4/Fred/Train.cpp

Go to the documentation of this file.
00001 Train::Train() {
00002     train_ID = -1;
00003     initfunctions();
00004 }
00005 
00006 void Train::initfunctions() {
00007     // Not sure of the syntax  ={
00008 
00009     *functions[0] = Train::nop( ... );      
00010     *functions[1] = Train::change_speed( ... );
00011     *functions[2] = Train::change_direction( ... );
00012 }
00013 
00014 void Train::run()
00015 {
00016     pid_t pid;
00017     int   task = 0;
00018 
00019     while(1)
00020     {
00021         const char* response;
00022         
00023         if((pid = Receive(0, buffer_, sizeof(buffer_))) < 0) 
00024         {
00025 
00026             printf("ERROR--code %d\n", errno);
00027             return;
00028         } else {
00029             task = buffer_->action;
00030             if ( task >= 0  &&  task < 26 ) {
00031                 functions[task]( buffer_ ); // Call the function to do...
00032             } else {
00033                 printf("Illegal task message request: %d", task );
00034             }
00035         }
00036 
00037         printf("Got from %d: %s\n", pid, buffer_);
00038         // send back
00039         Reply(pid, response, strlen(response)+1);
00040     }
00041     // send response and die
00042     Reply(pid, ok_response, sizeof(ok_response));
00043 }
00044 
00045 

Generated on Sun Oct 14 18:46:38 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001