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

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

Go to the documentation of this file.
00001 #ifndef __J2K__Train__Switch_CPP__
00002 #define __J2K__Train__Switch_CPP__
00003 
00004 Switch::Switch()
00005 {
00006   setSwitchID( 1 );
00007 }
00008 
00009 Switch::~Switch()
00010 {
00011   close( Output );          // DEBUG: Close output port
00012 }
00013 
00014 void Switch::setSwitchID( int ID )
00015 {
00016   SwitchID = ID;
00017   SwitchPosition = CLOSE;
00018   setSwitch( CLOSE );
00019 }
00020 
00021 void Switch::setSwitch( int P )
00022 {
00023   SwitchPosition = P;
00024   outp(0x182,3);
00025 
00026   if ( SwitchPosition == CLOSE ) {
00027 
00028     switch( SwitchID ) {
00029       case 1: outp(0x180,0xFD); break;
00030       case 2: outp(0x180,0xFB); break;
00031       case 3: outp(0x180,0xEF); break;
00032       case 4: outp(0x180,0x7F); break;
00033     }
00034 
00035   } else {
00036 
00037      switch( SwitchID ) {
00038        case 1: outp( 0x180, 0xFE ); break;
00039        case 2: outp( 0x180, 0xF7 ); break;
00040        case 3: outp( 0x180, 0xDF ); break;
00041        case 4: outp( 0x180, 0xBF ); break;
00042      }
00043   }
00044 
00045   delay( 200 );
00046   outp( 0x180, 0xFF );
00047 }
00048 
00049 int Switch::getSwitch()
00050 {
00051   return ( SwitchPosition == OPEN );
00052 }
00053 
00054 #endif

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