@Override public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) { OchSignal ochSignal = ((OchSignalCriterion) criterion).lambda(); ObjectNode child = root.putObject(CriterionCodec.OCH_SIGNAL_ID); child.put(CriterionCodec.GRID_TYPE, ochSignal.gridType().name()); child.put(CriterionCodec.CHANNEL_SPACING, ochSignal.channelSpacing().name()); child.put(CriterionCodec.SPACING_MULIPLIER, ochSignal.spacingMultiplier()); child.put(CriterionCodec.SLOT_GRANULARITY, ochSignal.slotGranularity()); return root; } }
/** * Returns a JSON Object representation of this instance. * * @param j Och signal object * @return JSON Object representing OchSignal */ public static ObjectNode encode(OchSignal j) { ObjectNode obj = MAPPER.createObjectNode(); obj.put("channelSpacing", j.channelSpacing().toString()); obj.put("gridType", j.gridType().toString()); obj.put("slotGranularity", j.slotGranularity()); obj.put("spacingMultiplier", j.spacingMultiplier()); return obj; }
@Override public Criterion decodeCriterion(ObjectNode json) { JsonNode ochSignalId = nullIsIllegal(json.get(CriterionCodec.OCH_SIGNAL_ID), CriterionCodec.GRID_TYPE + MISSING_MEMBER_MESSAGE); GridType gridType = GridType.valueOf( nullIsIllegal(ochSignalId.get(CriterionCodec.GRID_TYPE), CriterionCodec.GRID_TYPE + MISSING_MEMBER_MESSAGE).asText()); ChannelSpacing channelSpacing = ChannelSpacing.valueOf( nullIsIllegal(ochSignalId.get(CriterionCodec.CHANNEL_SPACING), CriterionCodec.CHANNEL_SPACING + MISSING_MEMBER_MESSAGE).asText()); int spacingMultiplier = nullIsIllegal(ochSignalId.get(CriterionCodec.SPACING_MULIPLIER), CriterionCodec.SPACING_MULIPLIER + MISSING_MEMBER_MESSAGE).asInt(); int slotGranularity = nullIsIllegal(ochSignalId.get(CriterionCodec.SLOT_GRANULARITY), CriterionCodec.SLOT_GRANULARITY + MISSING_MEMBER_MESSAGE).asInt(); return Criteria.matchLambda( Lambda.ochSignal(gridType, channelSpacing, spacingMultiplier, slotGranularity)); } }
} else if (ochSignal.gridType() == GridType.DWDM) { int startMultiplier = (int) (1 - ochSignal.slotGranularity() + ochSignal.spacingMultiplier() * ochSignal.channelSpacing().frequency().asHz() / ChannelSpacing.CHL_6P25GHZ.frequency().asHz()); return IntStream.range(0, ochSignal.slotGranularity()) .mapToObj(x -> OchSignal.newFlexGridSlot(startMultiplier + (2 * x)))
/** * Encode an L0 modification instruction. * * @param result json node that the instruction attributes are added to */ private void encodeL0(ObjectNode result) { L0ModificationInstruction l0Instruction = (L0ModificationInstruction) instruction; result.put(InstructionCodec.SUBTYPE, l0Instruction.subtype().name()); switch (l0Instruction.subtype()) { case OCH: L0ModificationInstruction.ModOchSignalInstruction ochSignalInstruction = (L0ModificationInstruction.ModOchSignalInstruction) l0Instruction; OchSignal ochSignal = ochSignalInstruction.lambda(); result.put(InstructionCodec.GRID_TYPE, ochSignal.gridType().name()); result.put(InstructionCodec.CHANNEL_SPACING, ochSignal.channelSpacing().name()); result.put(InstructionCodec.SPACING_MULTIPLIER, ochSignal.spacingMultiplier()); result.put(InstructionCodec.SLOT_GRANULARITY, ochSignal.slotGranularity()); break; default: log.info("Cannot convert L0 subtype of {}", l0Instruction.subtype()); } }
ChannelSpacing channelSpacing = ChannelSpacing.valueOf(channelSpacingString); if (channelSpacing == null) { throw new IllegalArgumentException("Unknown channel spacing "