use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.
the class OpenFlowLambdaQuery method signals.
private Set<OchSignal> signals(long min, long max, long grid) {
if (Spectrum.O_BAND_MIN.asMHz() > min) {
log.warn("Out of range frequency (below the O-band minimum)");
}
if (Spectrum.U_BAND_MAX.asMHz() < max) {
log.warn("Out of range frequency (above the U-band maximum)");
}
double centerFrequencyMHz = Spectrum.CENTER_FREQUENCY.asMHz();
long startSpacingMultiplier = (long) (min - centerFrequencyMHz) / grid;
long stopSpacingMultiplier = (long) (max - centerFrequencyMHz) / grid;
Set<OchSignal> signals = new LinkedHashSet<>();
if (grid == ChannelSpacing.CHL_100GHZ.frequency().asMHz()) {
signals = IntStream.rangeClosed((int) startSpacingMultiplier, (int) stopSpacingMultiplier).mapToObj(i -> new OchSignal(GridType.DWDM, ChannelSpacing.CHL_100GHZ, i, 8)).collect(GuavaCollectors.toImmutableSet());
} else if (grid == ChannelSpacing.CHL_50GHZ.frequency().asMHz()) {
signals = IntStream.rangeClosed((int) startSpacingMultiplier, (int) stopSpacingMultiplier).mapToObj(i -> new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, i, 4)).collect(GuavaCollectors.toImmutableSet());
} else if (grid == ChannelSpacing.CHL_25GHZ.frequency().asMHz()) {
signals = IntStream.rangeClosed((int) startSpacingMultiplier, (int) stopSpacingMultiplier).mapToObj(i -> new OchSignal(GridType.DWDM, ChannelSpacing.CHL_25GHZ, i, 2)).collect(GuavaCollectors.toImmutableSet());
} else if (grid == ChannelSpacing.CHL_12P5GHZ.frequency().asMHz()) {
signals = IntStream.rangeClosed((int) startSpacingMultiplier, (int) stopSpacingMultiplier).mapToObj(i -> new OchSignal(GridType.DWDM, ChannelSpacing.CHL_6P25GHZ, i, 1)).collect(GuavaCollectors.toImmutableSet());
} else if (grid == ChannelSpacing.CHL_6P25GHZ.frequency().asMHz()) {
// Only consider odd values for the multiplier (for easy mapping to fixed grid)
signals = IntStream.rangeClosed((int) startSpacingMultiplier, (int) stopSpacingMultiplier).filter(i -> i % 2 == 1).mapToObj(i -> new OchSignal(GridType.FLEX, ChannelSpacing.CHL_6P25GHZ, i, 1)).collect(GuavaCollectors.toImmutableSet());
} else {
log.warn("Unsupported channel spacing");
}
return signals;
}
use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.
the class ZteDeviceDiscoveryImpl method toPortDescriptionInternal.
private PortDescription toPortDescriptionInternal(HierarchicalConfiguration component) {
Map<String, String> annotations = new HashMap<>();
String name = component.getString("name");
String type = component.getString("state/type");
annotations.put(OdtnDeviceDescriptionDiscovery.OC_NAME, name);
annotations.put(OdtnDeviceDescriptionDiscovery.OC_TYPE, type);
annotations.putIfAbsent(AnnotationKeys.PORT_NAME, name);
// PORT-1-4-C1
String[] textStr = name.split("-");
// use different value of portNumber on the same equipment
String portComponentIndex = textStr[textStr.length - 1];
int slotIndex = Integer.parseInt(textStr[2]);
int slotPortIndex = Integer.parseInt(portComponentIndex.substring(1));
int portNumber = slotIndex * 10 + slotPortIndex;
annotations.putIfAbsent(ONOS_PORT_INDEX, portComponentIndex);
annotations.putIfAbsent(CONNECTION_ID, "connection:" + Integer.parseInt(portComponentIndex.substring(1)));
if (portComponentIndex.charAt(0) == 'L') {
// line
annotations.putIfAbsent(PORT_TYPE, OdtnPortType.LINE.value());
OchSignal signalId = OchSignal.newDwdmSlot(ChannelSpacing.CHL_50GHZ, 1);
return OchPortHelper.ochPortDescription(PortNumber.portNumber(portNumber + 100L), true, OduSignalType.ODUC2, true, signalId, DefaultAnnotations.builder().putAll(annotations).build());
} else if (portComponentIndex.charAt(0) == 'C') {
// client
annotations.putIfAbsent(PORT_TYPE, OdtnPortType.CLIENT.value());
Builder builder = DefaultPortDescription.builder();
builder.withPortNumber(PortNumber.portNumber(portNumber)).isEnabled(true).portSpeed(100000L).type(Type.PACKET).annotations(DefaultAnnotations.builder().putAll(annotations).build());
return builder.build();
}
return null;
}
use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.
the class PolatisPowerConfig method acquireTargetPower.
private Long acquireTargetPower(PortNumber port, T component) {
if (component instanceof OchSignal) {
log.warn("Channel power is not applicable.");
return null;
}
log.debug("Get port{} target power...", port);
DeviceId deviceId = handler().data().deviceId();
Long targetPower = 0L;
try {
targetPower = Long.valueOf(get(handler(), VOA_LEVEL_OID + "." + port.toLong()).toInt());
} catch (IOException e) {
log.error("Error reading target power for device {} exception {}", deviceId, e);
}
return targetPower;
}
use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.
the class CzechLightLambdaQuery method queryLambdas.
@Override
public Set<OchSignal> queryLambdas(PortNumber portNumber) {
DeviceService deviceService = this.handler().get(DeviceService.class);
Port port = deviceService.getPort(data().deviceId(), portNumber);
if ((port.type() == Port.Type.FIBER) || (port.type() == Port.Type.OMS)) {
final int startMultiplier50 = (int) (START_CENTER_FREQ_50.subtract(Spectrum.CENTER_FREQUENCY).asHz() / Frequency.ofGHz(50).asHz());
final int endMultiplier50 = (int) (END_CENTER_FREQ_50.subtract(Spectrum.CENTER_FREQUENCY).asHz() / Frequency.ofGHz(50).asHz());
return IntStream.range(startMultiplier50, endMultiplier50 + 1).mapToObj(x -> OchSignal.newDwdmSlot(ChannelSpacing.CHL_50GHZ, x)).collect(Collectors.toSet());
} else {
return Collections.emptySet();
}
}
use of org.onosproject.net.OchSignal in project onos by opennetworkinglab.
the class CienaWaveserverDeviceDescription method parseWaveServerCienaOchPorts.
public static PortDescription parseWaveServerCienaOchPorts(long portNumber, HierarchicalConfiguration config, SparseAnnotations annotations) {
final List<String> tunableType = Lists.newArrayList("performance-optimized", "accelerated");
final String flexGrid = "flex-grid";
final String state = "properties.transmitter.state";
final String tunable = "properties.modem.tx-tuning-mode";
final String spacing = "properties.line-system.wavelength-spacing";
final String frequency = "properties.transmitter.frequency.value";
boolean isEnabled = config.getString(state).equals(ENABLED);
boolean isTunable = tunableType.contains(config.getString(tunable));
GridType gridType = config.getString(spacing).equals(flexGrid) ? GridType.FLEX : null;
ChannelSpacing chSpacing = gridType == GridType.FLEX ? ChannelSpacing.CHL_6P25GHZ : null;
// Working in Ghz //(Nominal central frequency - 193.1)/channelSpacing = spacingMultiplier
final int baseFrequency = 193100;
long spacingFrequency = chSpacing == null ? baseFrequency : chSpacing.frequency().asHz();
int spacingMult = ((int) (toGbps(((int) config.getDouble(frequency) - baseFrequency)) / // FIXME is there a better way ?
toGbpsFromHz(spacingFrequency)));
return ochPortDescription(PortNumber.portNumber(portNumber), isEnabled, OduSignalType.ODU4, isTunable, new OchSignal(gridType, chSpacing, spacingMult, 1), annotations);
}
Aggregations