use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error in project bgpcep by opendaylight.
the class PCEPRequestMessageParser method getRequests.
protected List<Requests> getRequests(final List<Object> objects, final List<Message> errors) {
final List<Requests> requests = new ArrayList<>();
while (!objects.isEmpty()) {
final RequestsBuilder rBuilder = new RequestsBuilder();
Rp rpObj = null;
if (!(objects.get(0) instanceof Rp)) {
// if RP obj is missing return error only
errors.add(createErrorMsg(PCEPErrors.RP_MISSING, Optional.absent()));
return null;
}
rpObj = (Rp) objects.get(0);
objects.remove(0);
if (!rpObj.isProcessingRule()) {
errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.absent()));
} else {
rBuilder.setRp(rpObj);
}
final List<VendorInformationObject> vendorInfo = addVendorInformationObjects(objects);
if (!vendorInfo.isEmpty()) {
rBuilder.setVendorInformationObject(vendorInfo);
}
// expansion
if (rpObj.isPathKey() && objects.get(0) instanceof PathKey) {
rBuilder.setPathKeyExpansion(new PathKeyExpansionBuilder().setPathKey((PathKey) objects.get(0)).build());
}
final P2pBuilder p2pBuilder = new P2pBuilder();
if (!objects.isEmpty() && objects.get(0) instanceof EndpointsObj) {
final EndpointsObj ep = (EndpointsObj) objects.get(0);
objects.remove(0);
if (!ep.isProcessingRule()) {
errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.of(rpObj)));
} else {
p2pBuilder.setEndpointsObj(ep);
}
} else {
errors.add(createErrorMsg(PCEPErrors.END_POINTS_MISSING, Optional.of(rpObj)));
return null;
}
// p2p
if (!rpObj.isP2mp()) {
final SegmentComputation segm = getSegmentComputation(p2pBuilder, objects, errors, rpObj);
if (segm != null) {
rBuilder.setSegmentComputation(segm);
}
}
requests.add(rBuilder.build());
}
return requests;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error in project bgpcep by opendaylight.
the class PeerUpHandler method parseMessageBody.
@Override
public Notification parseMessageBody(final ByteBuf bytes) throws BmpDeserializationException {
final PeerUpNotificationBuilder peerUpNot = new PeerUpNotificationBuilder().setPeerHeader(parsePerPeerHeader(bytes));
if (peerUpNot.getPeerHeader().isIpv4()) {
bytes.skipBytes(Ipv6Util.IPV6_LENGTH - Ipv4Util.IP4_LENGTH);
peerUpNot.setLocalAddress(new IpAddress(Ipv4Util.addressForByteBuf(bytes)));
} else {
peerUpNot.setLocalAddress(new IpAddress(Ipv6Util.addressForByteBuf(bytes)));
}
peerUpNot.setLocalPort(new PortNumber(bytes.readUnsignedShort()));
peerUpNot.setRemotePort(new PortNumber(bytes.readUnsignedShort()));
try {
final Notification opSent = this.msgRegistry.parseMessage(bytes.readSlice(getBgpMessageLength(bytes)), null);
requireNonNull(opSent, "Error on parse Sent OPEN Message, Sent OPEN Message is null");
Preconditions.checkArgument(opSent instanceof OpenMessage, "An instance of OpenMessage notification is required");
final OpenMessage sent = (OpenMessage) opSent;
final Notification opRec = this.msgRegistry.parseMessage(bytes.readSlice(getBgpMessageLength(bytes)), null);
requireNonNull(opRec, "Error on parse Received OPEN Message, Received OPEN Message is null");
Preconditions.checkArgument(opRec instanceof OpenMessage, "An instance of OpenMessage notification is required");
final OpenMessage received = (OpenMessage) opRec;
peerUpNot.setSentOpen(new SentOpenBuilder(sent).build());
peerUpNot.setReceivedOpen(new ReceivedOpenBuilder(received).build());
final InformationBuilder infos = new InformationBuilder();
if (bytes.isReadable()) {
parseTlvs(infos, bytes);
peerUpNot.setInformation(infos.build());
}
} catch (final BGPDocumentedException | BGPParsingException e) {
throw new BmpDeserializationException("Error while parsing BGP Open Message.", e);
}
return peerUpNot.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error in project bgpcep by opendaylight.
the class RouteMonitoringMessageHandler method parseMessageBody.
@Override
public Notification parseMessageBody(final ByteBuf bytes) throws BmpDeserializationException {
final RouteMonitoringMessageBuilder routeMonitor = new RouteMonitoringMessageBuilder().setPeerHeader(parsePerPeerHeader(bytes));
try {
final Notification message = this.msgRegistry.parseMessage(bytes, null);
requireNonNull(message, "UpdateMessage may not be null");
Preconditions.checkArgument(message instanceof UpdateMessage, "An instance of UpdateMessage is required");
final UpdateMessage updateMessage = (UpdateMessage) message;
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.route.monitoring.message.Update update = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev171207.route.monitoring.message.UpdateBuilder(updateMessage).build();
routeMonitor.setUpdate(update);
} catch (final BGPDocumentedException | BGPParsingException e) {
throw new BmpDeserializationException("Error while parsing Update Message.", e);
}
return routeMonitor.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error in project bgpcep by opendaylight.
the class PCCSessionListener method onMessage.
@Override
public void onMessage(final PCEPSession psession, final Message message) {
LOG.trace("Received message: {}", message);
if (this.errorMode) {
// random error message
psession.sendMessage(createErrorMessage(message));
return;
}
if (message instanceof Pcupd) {
final Updates upd = ((Pcupd) message).getPcupdMessage().getUpdates().get(0);
this.tunnelManager.onMessagePcupd(upd, this);
} else if (message instanceof Pcinitiate) {
this.tunnelManager.onMessagePcInitiate(((Pcinitiate) message).getPcinitiateMessage().getRequests().get(0), this);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.Error in project javacv by bytedeco.
the class FlyCapture2FrameGrabber method start.
public void start() throws FrameGrabber.Exception {
// TODO: Default 30 ?
int f = FRAMERATE_30;
if (frameRate <= 0) {
f = FRAMERATE_30;
} else if (frameRate <= 1.876) {
f = FRAMERATE_1_875;
} else if (frameRate <= 3.76) {
f = FRAMERATE_3_75;
} else if (frameRate <= 7.51) {
f = FRAMERATE_7_5;
} else if (frameRate <= 15.01) {
f = FRAMERATE_15;
} else if (frameRate <= 30.01) {
f = FRAMERATE_30;
} else if (frameRate <= 60.01) {
f = FRAMERATE_60;
} else if (frameRate <= 120.01) {
f = FRAMERATE_120;
} else if (frameRate <= 240.01) {
f = FRAMERATE_240;
}
int c = VIDEOMODE_ANY;
if (imageMode == FrameGrabber.ImageMode.COLOR || imageMode == FrameGrabber.ImageMode.RAW) {
if (imageWidth <= 0 || imageHeight <= 0) {
c = VIDEOMODE_ANY;
} else if (imageWidth <= 640 && imageHeight <= 480) {
c = VIDEOMODE_640x480RGB;
} else if (imageWidth <= 800 && imageHeight <= 600) {
c = VIDEOMODE_800x600RGB;
} else if (imageWidth <= 1024 && imageHeight <= 768) {
c = VIDEOMODE_1024x768RGB;
} else if (imageWidth <= 1280 && imageHeight <= 960) {
c = VIDEOMODE_1280x960RGB;
} else if (imageWidth <= 1600 && imageHeight <= 1200) {
c = VIDEOMODE_1600x1200RGB;
}
} else if (imageMode == FrameGrabber.ImageMode.GRAY) {
if (imageWidth <= 0 || imageHeight <= 0) {
c = VIDEOMODE_ANY;
} else if (imageWidth <= 640 && imageHeight <= 480) {
c = bpp > 8 ? VIDEOMODE_640x480Y16 : VIDEOMODE_640x480Y8;
} else if (imageWidth <= 800 && imageHeight <= 600) {
c = bpp > 8 ? VIDEOMODE_800x600Y16 : VIDEOMODE_800x600Y8;
} else if (imageWidth <= 1024 && imageHeight <= 768) {
c = bpp > 8 ? VIDEOMODE_1024x768Y16 : VIDEOMODE_1024x768Y8;
} else if (imageWidth <= 1280 && imageHeight <= 960) {
c = bpp > 8 ? VIDEOMODE_1280x960Y16 : VIDEOMODE_1280x960Y8;
} else if (imageWidth <= 1600 && imageHeight <= 1200) {
c = bpp > 8 ? VIDEOMODE_1600x1200Y16 : VIDEOMODE_1600x1200Y8;
}
}
// set or reset trigger mode
TriggerMode tm = new TriggerMode();
Error error = camera.GetTriggerMode(tm);
if (error.notEquals(PGRERROR_OK)) {
PrintError(error);
throw new FrameGrabber.Exception("GetTriggerMode() Error " + error.GetDescription());
}
tm.onOff(triggerMode);
tm.source(7);
tm.mode(14);
tm.parameter(0);
error = camera.SetTriggerMode(tm);
if (error.notEquals(PGRERROR_OK)) {
// try with trigger mode 0 instead
tm.onOff(true);
tm.source(7);
tm.mode(0);
tm.parameter(0);
error = camera.SetTriggerMode(tm);
if (error.notEquals(PGRERROR_OK)) {
PrintError(error);
throw new FrameGrabber.Exception("SetTriggerMode() Error " + error.GetDescription());
}
}
if (triggerMode) {
waitForTriggerReady();
}
// try to match the endianness to our platform
error = camera.ReadRegister(IMAGE_DATA_FORMAT, regOut);
if (error.notEquals(PGRERROR_OK)) {
PrintError(error);
throw new FrameGrabber.Exception("ReadRegister(IMAGE_DATA_FORMAT, regOut) Error " + error.GetDescription());
}
int reg;
if (ByteOrder.nativeOrder().equals(ByteOrder.BIG_ENDIAN)) {
reg = regOut[0] | 0x1;
} else {
reg = regOut[0] & ~0x1;
}
error = camera.WriteRegister(IMAGE_DATA_FORMAT, reg);
if (error.notEquals(PGRERROR_OK)) {
PrintError(error);
throw new FrameGrabber.Exception("WriteRegister(IMAGE_DATA_FORMAT, reg) Error " + error.GetDescription());
}
// TODO: set fastest bus speed ? This may lead to system instability. Use default.
// set `gamma`
Property gammaProp = new Property(FlyCapture2.GAMMA);
if (gamma != 0.0) {
error = camera.GetProperty(gammaProp);
if (error.notEquals(PGRERROR_OK)) {
throw new FrameGrabber.Exception("GetProperty(gammaProp) Error " + error.GetDescription());
}
gammaProp.onOff(true);
gammaProp.absControl(true);
gammaProp.absValue((float) gamma);
camera.SetProperty(gammaProp);
error = camera.SetProperty(gammaProp);
if (error.notEquals(PGRERROR_OK)) {
PrintError(error);
throw new FrameGrabber.Exception("SetProperty(gammaProp) Error " + error.GetDescription());
}
}
error = camera.GetProperty(gammaProp);
if (error.notEquals(PGRERROR_OK)) {
gammaOut[0] = 2.2f;
} else {
gammaOut[0] = gammaProp.absValue();
}
// set `timeout`
error = camera.StartCapture();
if (error.notEquals(PGRERROR_OK)) {
PrintError(error);
throw new FrameGrabber.Exception("StartCapture() Error " + error.GetDescription());
}
// Get the camera configuration
FC2Config config = new FC2Config();
error = camera.GetConfiguration(config);
if (error.notEquals(PGRERROR_OK)) {
PrintError(error);
throw new FrameGrabber.Exception("GetConfiguration() Error " + error.GetDescription());
}
// Set the grab timeout to 5 seconds
config.grabTimeout(timeout);
// Set the camera configuration
error = camera.SetConfiguration(config);
if (error.notEquals(PGRERROR_OK)) {
PrintError(error);
throw new FrameGrabber.Exception("SetConfiguration() Error " + error.GetDescription());
}
}
Aggregations