Generic hardware access library
|
00001 #include "hal/ResetBitFactory.hh" 00002 00003 HAL::SequencerCommand* HAL::ResetBitFactory::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() < 1 || arguments.size() > 3 ) { 00009 throw ( HAL::SequencerSyntaxError("resetBit command must have one to 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::ResetBitFactory::create)"; 00019 throw (HAL::NoSuchItemException( text, __FILE__, __LINE__, __FUNCTION__ )); 00020 } 00021 00022 HAL::ResetBitCommand* commandPtr = new HAL::ResetBitCommand( item, sequence ); 00023 00024 if ( arguments.size() >= 1 ) { 00025 std::string verifyStr = arguments.front(); 00026 arguments.pop_front(); 00027 if (verifyStr == "HAL_DO_VERIFY") { 00028 commandPtr->setVerify(); 00029 } else if (verifyStr != "HAL_NO_VERIFY") { 00030 std::string text = "If present second argument must be 'HAL_DO_VERIFY' or 'HAL_NO_VERIFY'\n (HAL::ResetBitFactory::create)"; 00031 throw (HAL::SequencerSyntaxError( text )); 00032 ; 00033 } 00034 } 00035 00036 if ( arguments.size() >= 1 ) { 00037 std::string offsetStr = arguments.front(); 00038 arguments.pop_front(); 00039 if (offsetStr[0] != '$') { 00040 commandPtr->setOffset( stringToNumber( offsetStr )); 00041 } else { 00042 commandPtr->setOffsetPointer( sequence.getVariablePointer( offsetStr )); 00043 } 00044 } 00045 00046 return commandPtr; 00047 }