SqrtMethod.java 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package at.acdp.opcur.opc;
  2. /*
  3. * Copyright (c) 2016 Kevin Herron
  4. *
  5. * All rights reserved. This program and the accompanying materials
  6. * are made available under the terms of the Eclipse Public License v1.0
  7. * and Eclipse Distribution License v1.0 which accompany this distribution.
  8. *
  9. * The Eclipse Public License is available at
  10. * http://www.eclipse.org/legal/epl-v10.html
  11. * and the Eclipse Distribution License is available at
  12. * http://www.eclipse.org/org/documents/edl-v10.html.
  13. */
  14. import org.eclipse.milo.opcua.sdk.server.annotations.UaInputArgument;
  15. import org.eclipse.milo.opcua.sdk.server.annotations.UaMethod;
  16. import org.eclipse.milo.opcua.sdk.server.annotations.UaOutputArgument;
  17. import org.eclipse.milo.opcua.sdk.server.util.AnnotationBasedInvocationHandler.InvocationContext;
  18. import org.eclipse.milo.opcua.sdk.server.util.AnnotationBasedInvocationHandler.Out;
  19. import org.slf4j.Logger;
  20. import org.slf4j.LoggerFactory;
  21. public class SqrtMethod {
  22. private final Logger logger = LoggerFactory.getLogger(getClass());
  23. @UaMethod
  24. public void invoke(
  25. InvocationContext context,
  26. @UaInputArgument(
  27. name = "x",
  28. description = "A value.")
  29. Double x,
  30. @UaOutputArgument(
  31. name = "x_sqrt",
  32. description = "The positive square root of x. If the argument is NaN or less than zero, the result is NaN.")
  33. Out<Double> xSqrt) {
  34. System.out.println("sqrt(" + x.toString() + ")");
  35. logger.debug("Invoking sqrt() method of Object '{}'", context.getObjectNode().getBrowseName().getName());
  36. xSqrt.set(Math.sqrt(x));
  37. }
  38. }