Generic hardware access library
|
00001 #include "hal/CheckFactory.hh" 00002 00003 HAL::SequencerCommand* HAL::CheckFactory::create( std::list<std::string>& arguments, 00004 const HAL::AddressTableInterface& addressTable, 00005 HAL::CommandSequence& sequence ) 00006 throw (HAL::SequencerSyntaxError, HAL::NoSuchItemException) { 00007 00008 if ( arguments.size() < 2 ) { 00009 throw ( HAL::SequencerSyntaxError("check command must have at least two arguments.")); 00010 } 00011 std::string item = arguments.front(); 00012 arguments.pop_front(); 00013 // we check immediately if the item exists. So the program gets an 00014 // exception immediately and not only when the script is run 00015 if ( ! addressTable.exists( item ) ) { 00016 std::string text = "Item \"" + item + 00017 "\" does not exist in HAL::AddressTable" + 00018 "\n (HAL::CheckFactory::create)"; 00019 throw (HAL::NoSuchItemException( text, __FILE__, __LINE__, __FUNCTION__ )); 00020 } 00021 00022 HAL::CheckCommand* commandPtr = new HAL::CheckCommand (item, sequence); 00023 00024 std::string expectationStr = arguments.front(); 00025 arguments.pop_front(); 00026 if (expectationStr[0] != '$') { 00027 commandPtr->setExpectation( stringToNumber( expectationStr ) ); 00028 } else { 00029 commandPtr->setExpectationPointer( sequence.getVariablePointer( expectationStr )); 00030 } 00031 00032 if ( arguments.size() >= 1 ) { 00033 std::string offsetStr = arguments.front(); 00034 arguments.pop_front(); 00035 if (offsetStr[0] != '$') { 00036 commandPtr->setOffset( stringToNumber( offsetStr )); 00037 } else { 00038 commandPtr->setOffsetPointer( sequence.getVariablePointer( offsetStr )); 00039 } 00040 } 00041 00042 commandPtr->setFailMessage( arguments ); 00043 00044 return commandPtr; 00045 }