Generic hardware access library
|
00001 #include "hal/GotoCommand.hh" 00002 00003 00004 HAL::GotoCommand::GotoCommand( std::string labelName, 00005 std::string condition, 00006 HAL::CommandSequence& sequence ) 00007 throw (HAL::SequencerSyntaxError) 00008 : labelName(labelName), 00009 condition(condition), 00010 sequence(sequence) { 00011 op1 = 0; 00012 op2 = 0; 00013 op1Ptr = &op1; 00014 op2Ptr = &op2; 00015 // test the condition string for validity: 00016 if ( condition != "==" && 00017 condition != "!=" && 00018 condition != "<=" && 00019 condition != ">=" && 00020 condition != "<" && 00021 condition != ">" ) 00022 throw (HAL::SequencerSyntaxError("wrong condition string goto command.\n (HAL::GotoCommand::GotoCommand)")); 00023 } 00024 00025 void HAL::GotoCommand::setOp1( uint32_t op1 ) { 00026 this->op1 = op1; 00027 } 00028 00029 void HAL::GotoCommand::setOp2( uint32_t op2 ) { 00030 this->op2 = op2; 00031 } 00032 00033 void HAL::GotoCommand::setOp1Pointer( uint32_t* op1Ptr ) { 00034 this->op1Ptr = op1Ptr; 00035 } 00036 00037 void HAL::GotoCommand::setOp2Pointer( uint32_t* op2Ptr ) { 00038 this->op2Ptr = op2Ptr; 00039 } 00040 00041 void HAL::GotoCommand::excecute( const HAL::HardwareDeviceInterface& device ) const 00042 throw( HAL::SequencerSyntaxError ) { 00043 bool doJump = false; 00044 if ( condition == "==" ) { 00045 if ( *op1Ptr == *op2Ptr ) doJump = true; 00046 } else if ( condition == "<=" ) { 00047 if ( *op1Ptr <= *op2Ptr ) doJump = true; 00048 } else if ( condition == ">=" ) { 00049 if ( *op1Ptr >= *op2Ptr ) doJump = true; 00050 } else if ( condition == "<" ) { 00051 if ( *op1Ptr < *op2Ptr ) doJump = true; 00052 } else if ( condition == ">" ) { 00053 if ( *op1Ptr > *op2Ptr ) doJump = true; 00054 } else if ( condition == "!=" ) { 00055 if ( *op1Ptr != *op2Ptr ) doJump = true; 00056 } else { 00057 // here we should never arrive 00058 std::cout << "fatal software bug in GotoCommand.cc" << std::endl; 00059 } 00060 if (doJump) { 00061 sequence.gotoLabel( labelName ); 00062 } 00063 } 00064