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

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

Go to the documentation of this file.
00001 #ifndef __J2K__Train__Segment_CPP__
00002 #define __J2K__Train__Segment_CPP__
00003 
00004 Segment::Segment()
00005 {
00006   SegmentID = 1;
00007   SetSegmentID( SegmentID );
00008 }
00009 
00010 
00011 int Segment::mask( int bit )
00012 {
00013  int Pow = 1;
00014 
00015  for( int i = 0; i < bit; i++ ) { 
00016    Pow = Pow * 2;
00017  }
00018 
00019  return Pow; 
00020 }
00021 
00022 
00023 int Segment::isOccupied()
00024 {
00025   int  Occupied;
00026   char Output[100];  //  Output to the VT100 terminal.
00027   char Num[10];
00028  
00029   Port_Value = inp(Port_Address);
00030   Occupied   = Port_Value & ( mask( (SegmentID - 1) % 8 ) );
00031  
00032   itoa( SegmentID, Num, 10 );
00033   strcpy( Output, "" );
00034   strcat( Output,"Segment " );
00035   strcat( Output, Num );
00036 
00037 /*
00038   if ( Occupied == 0 ) {
00039     strcat(Output, " CLEAR.");
00040     DEBUG(Output);
00041   } else { 
00042     strcat(Output, " OCCUPIED.");
00043     DEBUG(Output);
00044   }
00045 */
00046 
00047   return ( Occupied == 0 );
00048 }
00049 
00050 void Segment::setSegmentID( int ID )
00051 {
00052   SegmentID = ID;
00053   Port_Address = 0x188;
00054 
00055   if ( SegmentID > 8 ) {
00056     Port_Address++;     // 0x189
00057   }
00058 }
00059 
00060 int Segment::getSegmentID() {
00061   return SegmentID;
00062 }
00063 
00064 void Segment::setNext( int ID ) {
00065   Next = ID;
00066 }
00067 
00068 int Segment::getNext() {
00069   return Next;
00070 }
00071 
00072 void Segment::setPrev( int ID ) {
00073   Previous = ID;
00074 }
00075 
00076 int Segment::getPrev() {
00077   return Previous;
00078 }
00079 
00080 #endif

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