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