ExtendedMultiplexingManager.cpp
Go to the documentation of this file.00001
00002
00003 #include <fesa-core/Synchronization/ExtendedMultiplexingManager.h>
00004
00005 #include <fesa-core/Synchronization/MultiplexingContext.h>
00006 #include <fesa-core/Exception/FesaException.h>
00007
00008
00009 namespace fesa
00010 {
00011
00012 ExtendedMultiplexingManager::ExtendedMultiplexingManager(const std::string& name,
00013 std::vector<std::string> extraCriterionCol, AbstractMultiplexingManager *baseMultiplexingManager) :
00014 AbstractMultiplexingManager(name, baseMultiplexingManager->getTimingDescriptor())
00015 {
00016 extraCriterionCol_ = extraCriterionCol;
00017 baseMultiplexingManager_ = baseMultiplexingManager;
00018 }
00019
00020 int32_t ExtendedMultiplexingManager::getDepth()
00021 {
00022
00023 return ((static_cast<int32_t>(extraCriterionCol_.size()) + 1) * baseMultiplexingManager_->getDepth());
00024 }
00025
00026 int32_t ExtendedMultiplexingManager::getSlot(MultiplexingContext& context)
00027 {
00028 int32_t slotOffset = getBlockOffset(context) * baseMultiplexingManager_->getDepth();
00029 return (slotOffset + baseMultiplexingManager_->getSlot(context));
00030 }
00031
00032 int32_t ExtendedMultiplexingManager::requireSlot(MultiplexingContext& context)
00033 {
00034 int32_t slotOffset = getBlockOffset(context) * baseMultiplexingManager_->getDepth();
00035 return (slotOffset * baseMultiplexingManager_->requireSlot(context));
00036 }
00037
00038 int32_t ExtendedMultiplexingManager::getBlockOffset(MultiplexingContext& ctx)
00039 {
00040 uint32_t i;
00041 bool found = false;
00042 if (ctx.getCycleStamp())
00043 {
00044 for (i = 0; i < extraCriterionCol_.size(); i++)
00045 {
00046 if (ctx.match(extraCriterionCol_[i]))
00047 {
00048 found = true;
00049 break;
00050 }
00051 }
00052
00053 if (!found)
00054 {
00055 i = 0;
00056 }
00057 }
00058 else
00059 {
00060 std::string str = ctx.getExtraCondition();
00061 if (str == "")
00062 {
00063 i = 0;
00064 }
00065 else
00066 {
00067 for (i = 0; i < extraCriterionCol_.size(); i++)
00068 {
00069 if (str == extraCriterionCol_[i])
00070 {
00071 found = true;
00072 break;
00073 }
00074 }
00075 if (!found)
00076 {
00077 throw FesaException(__FILE__, __LINE__, FesaErrorNotValidExtraCondition.c_str());
00078 }
00079 }
00080 }
00081 return i + 1;
00082 }
00083
00084 int32_t ExtendedMultiplexingManager::getLastSlot(const std::string& cycleName)
00085 {
00086 throw FesaException(__FILE__, __LINE__, FesaErrorMethodNotSupportedByMultiplexingManager.c_str());
00087 return 0;
00088 }
00089
00090 int32_t ExtendedMultiplexingManager::getLastSlot(const std::string& cycleName, const std::string& extraCriterion)
00091 {
00092 uint32_t i;
00093 bool found = false;
00094 for (i = 0; i < extraCriterionCol_.size(); i++)
00095 {
00096 if (extraCriterion == extraCriterionCol_[i])
00097 {
00098 found = true;
00099 break;
00100 }
00101 }
00102
00103 if (!found)
00104 {
00105 i = 0;
00106 }
00107
00108 uint32_t slotOffset = (i + 1) * baseMultiplexingManager_->getDepth();
00109 return (slotOffset + baseMultiplexingManager_->getLastSlot(cycleName));
00110 }
00111
00112 int32_t ExtendedMultiplexingManager::requireSlot(const std::string& cycleName)
00113 {
00114 throw FesaException(__FILE__, __LINE__, FesaErrorMethodNotSupportedByMultiplexingManager.c_str());
00115 return 0;
00116 }
00117
00118 int32_t ExtendedMultiplexingManager::requireSlot(const std::string& cycleName, const std::string& extraCriterion)
00119 {
00120 uint32_t i;
00121 bool found = false;
00122 for (i = 0; i < extraCriterionCol_.size(); i++)
00123 {
00124 if (extraCriterion == extraCriterionCol_[i])
00125 {
00126 found = true;
00127 break;
00128 }
00129 }
00130
00131 if (!found)
00132 {
00133 i = 0;
00134 }
00135
00136 uint32_t slotOffset = (i + 1) * baseMultiplexingManager_->getDepth();
00137 return (slotOffset + baseMultiplexingManager_->requireSlot(cycleName));
00138 }
00139
00140 int32_t ExtendedMultiplexingManager::getLastSlot(int32_t cycleId)
00141 {
00142 throw FesaException(__FILE__, __LINE__, FesaErrorMethodNotSupportedByMultiplexingManager.c_str());
00143 return 0;
00144 }
00145
00146 int32_t ExtendedMultiplexingManager::getLastSlot(int32_t cycleId, const std::string& extraCriterion)
00147 {
00148 uint32_t i;
00149 bool found = false;
00150 for (i = 0; i < extraCriterionCol_.size(); i++)
00151 {
00152 if (extraCriterion == extraCriterionCol_[i])
00153 {
00154 found = true;
00155 break;
00156 }
00157 }
00158
00159 if (!found)
00160 {
00161 i = 0;
00162 }
00163
00164 uint32_t slotOffset = (i + 1) * baseMultiplexingManager_->getDepth();
00165 return (slotOffset + baseMultiplexingManager_->getLastSlot(cycleId));
00166 }
00167
00168 int32_t ExtendedMultiplexingManager::requireSlot(int32_t cycleId)
00169 {
00170 throw FesaException(__FILE__, __LINE__, FesaErrorMethodNotSupportedByMultiplexingManager.c_str());
00171 return 0;
00172 }
00173
00174 int32_t ExtendedMultiplexingManager::requireSlot(int32_t cycleId, const std::string& extraCriterion)
00175 {
00176 uint32_t i;
00177 bool found = false;
00178 for (i = 0; i < extraCriterionCol_.size(); i++)
00179 {
00180 if (extraCriterion == extraCriterionCol_[i])
00181 {
00182 found = true;
00183 break;
00184 }
00185 }
00186
00187 if (!found)
00188 {
00189 i = 0;
00190 }
00191
00192 uint32_t slotOffset = (i + 1) * baseMultiplexingManager_->getDepth();
00193 return (slotOffset + baseMultiplexingManager_->requireSlot(cycleId));
00194 }
00195
00196 }