Generic hardware access library
|
00001 #include "hal/ReadFactory.hh" 00002 00003 HAL::SequencerCommand* HAL::ReadFactory::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 || arguments.size() > 3 ) { 00009 throw ( HAL::SequencerSyntaxError("read command must have two or three 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::ReadFactory::create)"; 00019 throw (HAL::NoSuchItemException( text, __FILE__, __LINE__, __FUNCTION__ )); 00020 } 00021 00022 HAL::ReadCommand* commandPtr = new HAL::ReadCommand (item, sequence); 00023 00024 std::string resultStr = arguments.front(); 00025 arguments.pop_front(); 00026 00027 if (resultStr[0] != '$') { 00028 throw ( HAL::SequencerSyntaxError("read command must have variable as second argument")); 00029 } else { 00030 commandPtr->setResultPointer( sequence.getVariablePointer( resultStr )); 00031 } 00032 00033 if ( arguments.size() >= 1 ) { 00034 std::string offsetStr = arguments.front(); 00035 arguments.pop_front(); 00036 if (offsetStr[0] != '$') { 00037 commandPtr->setOffset( stringToNumber( offsetStr )); 00038 } else { 00039 commandPtr->setOffsetPointer( sequence.getVariablePointer( offsetStr )); 00040 } 00041 } 00042 return commandPtr; 00043 }