Utility class with convenience functions for XML-Parsing. More...
#include <ConfigurationUtils.h>
Static Public Member Functions | |
static ecorecpp::MetaModelRepository_ptr | getPreloadedMMR () |
Loads the complete Model in the MetaModelRepository. | |
static void | resolveCommonAliases (ecorecpp::ModelRepository_ptr mr) |
Resolves links to Eclipse paths that can't be found. | |
static long | mac2long (std::string string) |
Converts MAC address from string to long. | |
static unsigned long | time2ticks (std::string string, double tick) |
Converts time from sting to ticks. | |
static double | freq2s (std::string string) |
Converts frequency from string to double. | |
static Device_Specification::DeviceSpecification_ptr | getDeviceSpecification (std::string device_name, Network_Configuration::NetworkConfig_ptr nc) |
Finds a DeviceSpecification from NetworkConfiguration by device name. | |
static int | getPortSerialNumber (System_Specification::Port_ptr port, Device_Target_Mapping::Mappings_ptr map) |
Returns the number of a port. | |
static string | getPortName (System_Specification::Port_ptr port, Device_Target_Mapping::Mappings_ptr map) |
Returns the name of a Port. | |
static int | getVLid (System_Specification::VirtualLink_ptr vl, Device_Target_Mapping::Mappings_ptr map) |
Returns the critical traffic id of a virtual link. | |
static System_Specification::VirtualLink_ptr | getVLfromVLid (int vlid, Device_Target_Mapping::Mappings_ptr map) |
Finds the virtual link object of a given critical traffic id. |
Utility class with convenience functions for XML-Parsing.
Definition at line 44 of file ConfigurationUtils.h.
double ConfigurationUtils::freq2s | ( | std::string | string | ) | [static] |
Converts frequency from string to double.
string | frequency as string e.g. "100MHZ allowed Units: "Mhz" |
Definition at line 79 of file ConfigurationUtils.cc.
Referenced by TTEthernetModel::ConfigurationManager::initialize().
00080 { 00081 double factor = 0; 00082 std::string::size_type pos; 00083 if ((pos = string.find("MHZ")) != std::string::npos || (pos = string.find("MHz")) != std::string::npos || (pos 00084 = string.find("Mhz")) != std::string::npos) 00085 { 00086 factor = 1000000; 00087 } 00088 if (pos != std::string::npos) 00089 string.erase(pos); 00090 return 1 / (::strtod(string.c_str(), 0) * factor); 00091 }
Device_Specification::DeviceSpecification_ptr ConfigurationUtils::getDeviceSpecification | ( | std::string | device_name, | |
Network_Configuration::NetworkConfig_ptr | nc | |||
) | [static] |
Finds a DeviceSpecification from NetworkConfiguration by device name.
device_name | Name of the device | |
nc | network configuration to search in |
Definition at line 93 of file ConfigurationUtils.cc.
Referenced by TTEthernetModel::ConfigurationManager::initialize().
00095 { 00096 ecorecpp::mapping::EList<Network_Configuration::DeviceReferringElement>& dreList = nc->getDeviceReferringElement(); 00097 for (unsigned int i = 0; i < dreList.size(); i++) 00098 { 00099 Network_Configuration::DeviceReferringElement_ptr dre = dreList.get(i); 00100 if (!dre->getRefDevice()->getName().compare(device_name)) 00101 { 00102 return dre->getRefDeviceSpecification(); 00103 } 00104 } 00105 return NULL; 00106 }
string ConfigurationUtils::getPortName | ( | System_Specification::Port_ptr | port, | |
Device_Target_Mapping::Mappings_ptr | map | |||
) | [static] |
Returns the name of a Port.
port | Pointer to the Port | |
map | Pointer to the Device_Target_Mapping |
Definition at line 156 of file ConfigurationUtils.cc.
Referenced by TTEthernetModel::ConfigurationManager::initialize().
00157 { 00158 ecorecpp::mapping::EList<Device_Target_Mapping::DeviceMapping>& devicemapList = 00159 map->getDeviceMappings()->getDeviceMapping(); 00160 for (unsigned int i = 0; i < devicemapList.size(); i++) 00161 { 00162 Device_Target_Mapping::PortMappings_ptr pms = devicemapList.get(i)->getPortMappings(); 00163 // Switch Portmappings 00164 if (!pms->eClass()->getName().compare("SwPortMappings")) 00165 { 00166 ecorecpp::mapping::EList<Device_Target_Mapping::SwPortMapping>& portmapList = pms->as< 00167 Device_Target_Mapping::SwPortMappings> ()->getTargetPortMapping(); 00168 //Go through port mappings 00169 for (unsigned int j = 0; j < portmapList.size(); j++) 00170 { 00171 Device_Target_Mapping::SwPortMapping_ptr pm = portmapList.get(j); 00172 std::string refname = pm->getRefPort()->getName(); 00173 //If reference device is our device 00174 if (!pm->getRefPort()->getName().compare(port->getName())) 00175 { 00176 return pm->getRefTargetPort()->getName(); 00177 } 00178 } 00179 } 00180 // EndSystem Portmappings 00181 else if (!pms->eClass()->getName().compare("EsPortMappings")) 00182 { 00183 ecorecpp::mapping::EList<Device_Target_Mapping::EsPortMapping>& portmapList = pms->as< 00184 Device_Target_Mapping::EsPortMappings> ()->getTargetPortMapping(); 00185 //Go through port mappings 00186 for (unsigned int j = 0; j < portmapList.size(); j++) 00187 { 00188 Device_Target_Mapping::EsPortMapping_ptr pm = portmapList.get(j); 00189 //If reference device is our device and PHY is found we have a physical port 00190 if (!pm->getRefPort()->getName().compare(port->getName())) 00191 { 00192 return pm->getRefTargetPort()->getName(); 00193 } 00194 } 00195 } 00196 } 00197 return NULL; 00198 }
int ConfigurationUtils::getPortSerialNumber | ( | System_Specification::Port_ptr | port, | |
Device_Target_Mapping::Mappings_ptr | map | |||
) | [static] |
Returns the number of a port.
port | Pointer to the Port | |
map | Pointer to the Device_Target_Mapping |
Definition at line 108 of file ConfigurationUtils.cc.
Referenced by TTEthernetModel::ConfigurationManager::initialize().
00110 { 00111 ecorecpp::mapping::EList<Device_Target_Mapping::DeviceMapping>& devicemapList = 00112 map->getDeviceMappings()->getDeviceMapping(); 00113 for (unsigned int i = 0; i < devicemapList.size(); i++) 00114 { 00115 Device_Target_Mapping::PortMappings_ptr pms = devicemapList.get(i)->getPortMappings(); 00116 // Switch Portmappings 00117 if (!pms->eClass()->getName().compare("SwPortMappings")) 00118 { 00119 ecorecpp::mapping::EList<Device_Target_Mapping::SwPortMapping>& portmapList = pms->as< 00120 Device_Target_Mapping::SwPortMappings> ()->getTargetPortMapping(); 00121 //Go through port mappings 00122 for (unsigned int j = 0; j < portmapList.size(); j++) 00123 { 00124 Device_Target_Mapping::SwPortMapping_ptr pm = portmapList.get(j); 00125 std::string refname = pm->getRefPort()->getName(); 00126 std::string pname = port->getName(); 00127 //If reference device is our device and PHY is found we have a physical port 00128 if (!pm->getRefPort()->getName().compare(port->getName()) && !pm->getRefTargetPort()->getName().find( 00129 "PHY") != -1) 00130 { 00131 return pm->getRefTargetPort()->getPortSerialNumber(); 00132 } 00133 } 00134 } 00135 // EndSystem Portmappings 00136 else if (!pms->eClass()->getName().compare("EsPortMappings")) 00137 { 00138 ecorecpp::mapping::EList<Device_Target_Mapping::EsPortMapping>& portmapList = pms->as< 00139 Device_Target_Mapping::EsPortMappings> ()->getTargetPortMapping(); 00140 //Go through port mappings 00141 for (unsigned int j = 0; j < portmapList.size(); j++) 00142 { 00143 Device_Target_Mapping::EsPortMapping_ptr pm = portmapList.get(j); 00144 //If reference device is our device and PHY is found we have a physical port 00145 if (!pm->getRefPort()->getName().compare(port->getName()) && !pm->getRefTargetPort()->getName().find( 00146 "PHY") != -1) 00147 { 00148 return pm->getRefTargetPort()->getPortSerialNumber(); 00149 } 00150 } 00151 } 00152 } 00153 return -1; 00154 }
ecorecpp::MetaModelRepository_ptr ConfigurationUtils::getPreloadedMMR | ( | ) | [static] |
Loads the complete Model in the MetaModelRepository.
Definition at line 23 of file ConfigurationUtils.cc.
Referenced by TTEthernetModel::ConfigurationManager::initialize().
00024 { 00025 ecorecpp::MetaModelRepository_ptr mmr = ecorecpp::MetaModelRepository::_instance(); 00026 mmr->load(Network_Configuration::Network_ConfigurationPackage::_instance()); 00027 mmr->load(System_Specification::System_SpecificationPackage::_instance()); 00028 mmr->load(Device_Target_Mapping::Device_Target_MappingPackage::_instance()); 00029 mmr->load(Device_Specification::Device_SpecificationPackage::_instance()); 00030 mmr->load(Device_Targets::Device_TargetsPackage::_instance()); 00031 mmr->load(Protocol_Definition::Protocol_DefinitionPackage::_instance()); 00032 mmr->load(IP_Configuration::IP_ConfigurationPackage::_instance()); 00033 mmr->load(Virtuallink_Map::Virtuallink_MapPackage::_instance()); 00034 return mmr; 00035 }
System_Specification::VirtualLink_ptr ConfigurationUtils::getVLfromVLid | ( | int | vlid, | |
Device_Target_Mapping::Mappings_ptr | map | |||
) | [static] |
Finds the virtual link object of a given critical traffic id.
vlid | critical traffic id | |
map | Pointer to the Device_Target_Mapping |
Definition at line 215 of file ConfigurationUtils.cc.
00217 { 00218 Virtuallink_Map::VirtualLinkMapping_ptr vlming = map->getRefVirtualLinkMappings(); 00219 ecorecpp::mapping::EList<Virtuallink_Map::VirtualLinkMap>& vlmList = vlming->getVirtualLinkMap(); 00220 for (unsigned int j = 0; j < vlmList.size(); j++) 00221 { 00222 Virtuallink_Map::VirtualLinkMap_ptr vlm = vlmList.get(j); 00223 if (vlm->getId() == vlid) 00224 { 00225 return vlm->getRefVirtualLink(); 00226 } 00227 } 00228 //NOT FOUND 00229 return 0; 00230 }
int ConfigurationUtils::getVLid | ( | System_Specification::VirtualLink_ptr | vl, | |
Device_Target_Mapping::Mappings_ptr | map | |||
) | [static] |
Returns the critical traffic id of a virtual link.
vl | Pointer to the virtual link | |
map | Pointer to the Device_Target_Mapping |
Definition at line 200 of file ConfigurationUtils.cc.
Referenced by TTEthernetModel::ConfigurationManager::initialize().
00201 { 00202 Virtuallink_Map::VirtualLinkMapping_ptr vlming = map->getRefVirtualLinkMappings(); 00203 ecorecpp::mapping::EList<Virtuallink_Map::VirtualLinkMap>& vlmList = vlming->getVirtualLinkMap(); 00204 for (unsigned int j = 0; j < vlmList.size(); j++) 00205 { 00206 Virtuallink_Map::VirtualLinkMap_ptr vlm = vlmList.get(j); 00207 if (!vlm->getRefVirtualLink()->getVlid().compare(vl->getVlid())) 00208 { 00209 return vlm->getId(); 00210 } 00211 } 00212 return -1; 00213 }
long ConfigurationUtils::mac2long | ( | std::string | string | ) | [static] |
Converts MAC address from string to long.
string | with ":" seperated hex bytes e.g. "01:02:03:04:05:06" |
Definition at line 47 of file ConfigurationUtils.cc.
Referenced by TTEthernetModel::ConfigurationManager::initialize().
void ConfigurationUtils::resolveCommonAliases | ( | ecorecpp::ModelRepository_ptr | mr | ) | [static] |
Resolves links to Eclipse paths that can't be found.
mr | Pointer to the ModelRepository that should be fixed |
Definition at line 37 of file ConfigurationUtils.cc.
Referenced by TTEthernetModel::ConfigurationManager::initialize().
00038 { 00039 mr->addAlias("platform:/plugin/com.tttech.tte.targetdevices/data/TTE_Prot_Layer_100M.device_targets", 00040 "TTE_Prot_Layer_100M.device_targets"); 00041 mr->addAlias("platform:/plugin/com.tttech.tte.targetdevices/data/TTE_Dev_Switch_8port_100M_V2.device_targets", 00042 "TTE_Dev_Switch_8port_100M_V2.device_targets"); 00043 mr->addAlias("platform:/plugin/com.tttech.tte.models/data/PredefinedIntegrityConfigurations.network_config", 00044 "PredefinedIntegrityConfigurations.network_config"); 00045 }
unsigned long ConfigurationUtils::time2ticks | ( | std::string | string, | |
double | tick | |||
) | [static] |
Converts time from sting to ticks.
string | time as string e.g. "10us" allowed units: "s", "ms", "us", "ns" | |
tick | length of one tick in nanoseconds |
Definition at line 55 of file ConfigurationUtils.cc.
Referenced by TTEthernetModel::ConfigurationManager::initialize().
00056 { 00057 double factor = 0; 00058 std::string::size_type pos; 00059 if ((pos = string.find("ns")) != std::string::npos) 00060 { 00061 factor = 1000000000; 00062 } 00063 else if ((pos = string.find("us")) != std::string::npos) 00064 { 00065 factor = 1000000; 00066 } 00067 else if ((pos = string.find("ms")) != std::string::npos) 00068 { 00069 factor = 1000; 00070 } 00071 else if ((pos = string.find("s")) != std::string::npos) 00072 factor = 1; 00073 00074 if (pos != std::string::npos) 00075 string.erase(pos); 00076 return round(::strtod(string.c_str(), 0) / (tick * factor)); 00077 }