Search in sources :

Example 56 with OchSignal

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);
}
Also used : ChannelSpacing(org.onosproject.net.ChannelSpacing) OchSignal(org.onosproject.net.OchSignal) JsonNode(com.fasterxml.jackson.databind.JsonNode) GridType(org.onosproject.net.GridType)

Example 57 with OchSignal

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));
}
Also used : Frequency(org.onlab.util.Frequency) OchSignal(org.onosproject.net.OchSignal)

Example 58 with OchSignal

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));
}
Also used : OchSignal(org.onosproject.net.OchSignal)

Example 59 with OchSignal

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);
}
Also used : PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) Criterion(org.onosproject.net.flow.criteria.Criterion) OchSignalCriterion(org.onosproject.net.flow.criteria.OchSignalCriterion) OchSignal(org.onosproject.net.OchSignal) Instructions(org.onosproject.net.flow.instructions.Instructions) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) PortNumber(org.onosproject.net.PortNumber) Instruction(org.onosproject.net.flow.instructions.Instruction)

Example 60 with 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;
}
Also used : LambdaQuery(org.onosproject.net.behaviour.LambdaQuery) OchSignal(org.onosproject.net.OchSignal)

Aggregations

OchSignal (org.onosproject.net.OchSignal)63 PortNumber (org.onosproject.net.PortNumber)17 ChannelSpacing (org.onosproject.net.ChannelSpacing)16 GridType (org.onosproject.net.GridType)14 DeviceId (org.onosproject.net.DeviceId)12 ConnectPoint (org.onosproject.net.ConnectPoint)11 DeviceService (org.onosproject.net.device.DeviceService)10 HashMap (java.util.HashMap)9 Set (java.util.Set)9 IntStream (java.util.stream.IntStream)9 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 Logger (org.slf4j.Logger)8 ArrayList (java.util.ArrayList)7 Port (org.onosproject.net.Port)7 Collectors (java.util.stream.Collectors)6 HierarchicalConfiguration (org.apache.commons.configuration.HierarchicalConfiguration)6 AbstractHandlerBehaviour (org.onosproject.net.driver.AbstractHandlerBehaviour)6 Collections (java.util.Collections)5 List (java.util.List)5 Frequency (org.onlab.util.Frequency)5