use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.
the class OchSignalCodec method decode.
/**
* Creates an instance of {@link OchSignal} from JSON representation.
*
* @param obj JSON Object representing OchSignal
* @return OchSignal
* @throws IllegalArgumentException - if JSON object is ill-formed
* @see OchSignalCodec#encode(OchSignal)
*/
public static OchSignal decode(ObjectNode obj) {
final GridType gridType;
final ChannelSpacing channelSpacing;
final int spacingMultiplier;
final int slotGranularity;
String s;
s = obj.get("channelSpacing").textValue();
checkArgument(s != null, "ill-formed channelSpacing");
channelSpacing = Enum.valueOf(ChannelSpacing.class, s);
s = obj.get("gridType").textValue();
checkArgument(s != null, "ill-formed gridType");
gridType = Enum.valueOf(GridType.class, s);
JsonNode node;
node = obj.get("spacingMultiplier");
checkArgument(node.canConvertToInt(), "ill-formed spacingMultiplier");
spacingMultiplier = node.asInt();
node = obj.get("slotGranularity");
checkArgument(node.canConvertToInt(), "ill-formed slotGranularity");
slotGranularity = node.asInt();
return new OchSignal(gridType, channelSpacing, spacingMultiplier, slotGranularity);
}
use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.
the class OpticalChannelUtility method createOchSignalFromBounds.
/**
* This method creates OchSignal instance from frequency bounds.
* @param lowerBound - lower bound of the frequency.
* @param upperBound - upper bound of the frequency.
* @param gridType - type of the frequency grid.
* @param channelSpacing - channel spacing.
* @return - returns created instance of OchSignal.
*/
public static final OchSignal createOchSignalFromBounds(Frequency lowerBound, Frequency upperBound, GridType gridType, ChannelSpacing channelSpacing) {
// Transferring everything to the frequencies
Frequency slotWidth = upperBound.subtract(lowerBound);
Frequency halfBw = slotWidth.floorDivision(2);
Frequency centralFrequency = lowerBound.add(halfBw);
int spacingMultiplier = computeSpacingMultiplier(centralFrequency, channelSpacing);
int slotGranularity = computeSlotGranularity(slotWidth);
return (new OchSignal(gridType, channelSpacing, spacingMultiplier, slotGranularity));
}
use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.
the class OpticalChannelUtility method createOchSignal.
/**
* This method creates OchSignal instance based on Central Frequency and
* the Slot Width of the channel.
* @param centralFrequency - central frequency of the connection.
* @param slotWidth - bandwidth of the optical channel.
* @param gridType - type of the frequency grid.
* @param channelSpacing - channel spacing.
* @return - returns created instance of OchSignal.
*/
public static final OchSignal createOchSignal(Frequency centralFrequency, Frequency slotWidth, GridType gridType, ChannelSpacing channelSpacing) {
int spacingMultiplier = computeSpacingMultiplier(centralFrequency, channelSpacing);
int slotGranularity = computeSlotGranularity(slotWidth);
return (new OchSignal(gridType, channelSpacing, spacingMultiplier, slotGranularity));
}
use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.
the class ChannelData method fromFlow.
/**
* Returns a ChannelData representation from a flow rule. The rule must contain
* a Criterion.Type.IN_PORT selector, Criterion.Type.OCH_SIGID selector, and
* Instruction.Type.OUTPUT instruction.
*
* @param rule the flow rule representing the connection
* @return ChannelData representation of the connection
*/
public static ChannelData fromFlow(FlowRule rule) {
checkNotNull(rule);
Criterion in = rule.selector().getCriterion(Criterion.Type.IN_PORT);
checkNotNull(in);
PortNumber inPort = ((PortCriterion) in).port();
Criterion och = rule.selector().getCriterion(Criterion.Type.OCH_SIGID);
OchSignal ochSignal = och == null ? null : ((OchSignalCriterion) och).lambda();
PortNumber outPort = null;
List<Instruction> instructions = rule.treatment().allInstructions();
for (Instruction ins : instructions) {
if (ins.type() == Instruction.Type.OUTPUT) {
outPort = ((Instructions.OutputInstruction) ins).port();
}
}
checkNotNull(outPort);
return new ChannelData(inPort, outPort, ochSignal);
}
use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.
the class RoadmManager method validChannel.
@Override
public boolean validChannel(DeviceId deviceId, PortNumber portNumber, OchSignal ochSignal) {
checkNotNull(deviceId);
checkNotNull(portNumber);
checkNotNull(ochSignal);
LambdaQuery lambdaQuery = getLambdaQuery(deviceId);
if (lambdaQuery != null) {
Set<OchSignal> channels = lambdaQuery.queryLambdas(portNumber);
return channels.contains(ochSignal);
}
return false;
}
Aggregations