Search in sources :

Example 1 with GridType

use of org.onosproject.net.GridType in project onos by opennetworkinglab.

the class RoadmCrossConnectCommand method createOchSignal.

/**
 * This method forms parameters and creates and OchSignal instance from
 * central frequency and the slot width of the channel.
 * @param frequency - central frequency of the connection.
 * @param sw - slot width of the optical channel.
 * @param grid - frequency grid type.
 * @param spacing - channel spacing.
 * @return - returns created instance of OchSignal.
 */
protected OchSignal createOchSignal(String frequency, String sw, String grid, String spacing) {
    Frequency centralFreq = Frequency.ofGHz(Double.parseDouble(frequency));
    Frequency slotWidth = Frequency.ofGHz(Double.parseDouble(sw));
    GridType gridType = null;
    try {
        gridType = GridType.valueOf(grid.toUpperCase());
    } catch (Exception e) {
        gridType = GridType.DWDM;
    }
    ChannelSpacing channelSpacing = null;
    // It requires passing channelSpacing in the following format CHL_6P25GHZ or similar
    try {
        channelSpacing = ChannelSpacing.valueOf(spacing);
    } catch (Exception e) {
        channelSpacing = ChannelSpacing.CHL_50GHZ;
    }
    return OpticalChannelUtility.createOchSignal(centralFreq, slotWidth, gridType, channelSpacing);
}
Also used : ChannelSpacing(org.onosproject.net.ChannelSpacing) Frequency(org.onlab.util.Frequency) GridType(org.onosproject.net.GridType)

Example 2 with GridType

use of org.onosproject.net.GridType in project onos by opennetworkinglab.

the class RoadmUtil method createOchSignalFromWavelength.

public static OchSignal createOchSignalFromWavelength(double wavelength, DeviceService deviceService, DeviceId deviceId, PortNumber portNumber) {
    if (wavelength == 0L) {
        return null;
    }
    Port port = deviceService.getPort(deviceId, portNumber);
    Optional<OchPort> ochPortOpt = OchPortHelper.asOchPort(port);
    if (ochPortOpt.isPresent()) {
        OchPort ochPort = ochPortOpt.get();
        GridType gridType = ochPort.lambda().gridType();
        ChannelSpacing channelSpacing = ochPort.lambda().channelSpacing();
        int slotGranularity = ochPort.lambda().slotGranularity();
        int multiplier = getMultiplier(wavelength, gridType, channelSpacing);
        return new OchSignal(gridType, channelSpacing, multiplier, slotGranularity);
    } else {
        return null;
    }
}
Also used : ChannelSpacing(org.onosproject.net.ChannelSpacing) Port(org.onosproject.net.Port) OchPort(org.onosproject.net.optical.OchPort) OchSignal(org.onosproject.net.OchSignal) OchPort(org.onosproject.net.optical.OchPort) GridType(org.onosproject.net.GridType)

Example 3 with GridType

use of org.onosproject.net.GridType in project onos by opennetworkinglab.

the class PortWaveLengthCommand method createOchSignalFromWavelength.

private OchSignal createOchSignalFromWavelength(DeviceService deviceService, ConnectPoint cp) {
    long wavelength = Long.parseLong(parameter);
    if (wavelength == 0L) {
        return null;
    }
    Port port = deviceService.getPort(cp);
    Optional<OchPort> ochPortOpt = OchPortHelper.asOchPort(port);
    if (ochPortOpt.isPresent()) {
        OchPort ochPort = ochPortOpt.get();
        GridType gridType = ochPort.lambda().gridType();
        ChannelSpacing channelSpacing = ochPort.lambda().channelSpacing();
        int slotGranularity = ochPort.lambda().slotGranularity();
        int multiplier = getMultplier(wavelength, gridType, channelSpacing);
        return new OchSignal(gridType, channelSpacing, multiplier, slotGranularity);
    } else {
        print("[ERROR] connect point %s is not OChPort", cp);
        return null;
    }
}
Also used : ChannelSpacing(org.onosproject.net.ChannelSpacing) Port(org.onosproject.net.Port) OchPort(org.onosproject.net.optical.OchPort) OchSignal(org.onosproject.net.OchSignal) OchPort(org.onosproject.net.optical.OchPort) ConnectPoint(org.onosproject.net.ConnectPoint) GridType(org.onosproject.net.GridType)

Example 4 with GridType

use of org.onosproject.net.GridType in project onos by opennetworkinglab.

the class PortWaveLengthCommand method createOchSignal.

private OchSignal createOchSignal() throws IllegalArgumentException {
    if (parameter == null) {
        return null;
    }
    try {
        String[] splitted = parameter.split("/");
        checkArgument(splitted.length == 4, "signal requires 4 parameters: " + SIGNAL_FORMAT);
        int slotGranularity = Integer.parseInt(splitted[0]);
        String chSpacing = splitted[1];
        ChannelSpacing channelSpacing = checkNotNull(CHANNEL_SPACING_MAP.get(chSpacing), String.format("invalid channel spacing: %s", chSpacing));
        int multiplier = Integer.parseInt(splitted[2]);
        String gdType = splitted[3].toUpperCase();
        GridType gridType = GridType.valueOf(gdType);
        return new OchSignal(gridType, channelSpacing, multiplier, slotGranularity);
    } catch (RuntimeException e) {
        /* catching RuntimeException as both NullPointerException (thrown by
             * checkNotNull) and IllegalArgumentException (thrown by checkArgument)
             * are subclasses of RuntimeException.
             */
        String msg = String.format("Invalid signal format: %s, expected format is %s.", parameter, SIGNAL_FORMAT);
        print(msg);
        throw new IllegalArgumentException(msg, e);
    }
}
Also used : ChannelSpacing(org.onosproject.net.ChannelSpacing) OchSignal(org.onosproject.net.OchSignal) ConnectPoint(org.onosproject.net.ConnectPoint) GridType(org.onosproject.net.GridType)

Example 5 with GridType

use of org.onosproject.net.GridType in project onos by opennetworkinglab.

the class DecodeInstructionCodecHelper method decodeL0.

/**
 * Decodes a Layer 0 instruction.
 *
 * @return instruction object decoded from the JSON
 * @throws IllegalArgumentException if the JSON is invalid
 */
private Instruction decodeL0() {
    String subType = nullIsIllegal(json.get(InstructionCodec.SUBTYPE), InstructionCodec.SUBTYPE + InstructionCodec.ERROR_MESSAGE).asText();
    if (subType.equals(L0ModificationInstruction.L0SubType.OCH.name())) {
        String gridTypeString = nullIsIllegal(json.get(InstructionCodec.GRID_TYPE), InstructionCodec.GRID_TYPE + InstructionCodec.MISSING_MEMBER_MESSAGE).asText();
        GridType gridType = GridType.valueOf(gridTypeString);
        if (gridType == null) {
            throw new IllegalArgumentException("Unknown grid type  " + gridTypeString);
        }
        String channelSpacingString = nullIsIllegal(json.get(InstructionCodec.CHANNEL_SPACING), InstructionCodec.CHANNEL_SPACING + InstructionCodec.MISSING_MEMBER_MESSAGE).asText();
        ChannelSpacing channelSpacing = ChannelSpacing.valueOf(channelSpacingString);
        if (channelSpacing == null) {
            throw new IllegalArgumentException("Unknown channel spacing  " + channelSpacingString);
        }
        int spacingMultiplier = nullIsIllegal(json.get(InstructionCodec.SPACING_MULTIPLIER), InstructionCodec.SPACING_MULTIPLIER + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt();
        int slotGranularity = nullIsIllegal(json.get(InstructionCodec.SLOT_GRANULARITY), InstructionCodec.SLOT_GRANULARITY + InstructionCodec.MISSING_MEMBER_MESSAGE).asInt();
        return Instructions.modL0Lambda(new OchSignal(gridType, channelSpacing, spacingMultiplier, slotGranularity));
    }
    throw new IllegalArgumentException("L0 Instruction subtype " + subType + " is not supported");
}
Also used : ChannelSpacing(org.onosproject.net.ChannelSpacing) OchSignal(org.onosproject.net.OchSignal) HexString(org.onlab.util.HexString) GridType(org.onosproject.net.GridType)

Aggregations

ChannelSpacing (org.onosproject.net.ChannelSpacing)11 GridType (org.onosproject.net.GridType)11 OchSignal (org.onosproject.net.OchSignal)9 ConnectPoint (org.onosproject.net.ConnectPoint)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 LinkedHashSet (java.util.LinkedHashSet)2 Port (org.onosproject.net.Port)2 OchPort (org.onosproject.net.optical.OchPort)2 Frequency (org.onlab.util.Frequency)1 HexString (org.onlab.util.HexString)1 LambdaConfig (org.onosproject.driver.optical.config.LambdaConfig)1 NetworkConfigService (org.onosproject.net.config.NetworkConfigService)1