Handling setpoints inbound from DNP3 (or any other protocol)

10 views
Skip to first unread message

Adam Todorski

unread,
Mar 12, 2012, 6:59:11 PM3/12/12
to reef-...@googlegroups.com
I'm trying to consume setpoints through reef that are being set by an external DNP3 master (reef is in this case the slave).  I don't see an example of this in the examples (which are otherwise excellent, by the way!), so I came up with the following:

        CommandService commandService = client.getService(CommandService.class);

        // endpoint is the Entity for which I wish to handle inbound setpoint commands

        commandService.bindCommandHandler(endpoint.getUuid(),
                new CommandRequestHandler() {

            @Override
            public void handleCommandRequest(CommandRequest request,
                    CommandResultCallback callback) {
               
                // do something with the request...

                // respond to caller
                callback.setCommandResult(CommandStatus.SUCCESS);
            }

        }
        );

This blows up when I register it with:
org.totalgrid.reef.client.exception.ExpectationException: Expected a response list of size 1, but got a list of size: 0
at org.totalgrid.reef.client.sapi.client.Expectations$class.one(Expectations.scala:35)[60:org.totalgrid.reef.client:0.4.0]
        at org.totalgrid.reef.client.sapi.client.SuccessResponse.one(ServiceTypes.scala:81)[60:org.totalgrid.reef.client:0.4.0]
        at org.totalgrid.reef.client.sapi.rpc.impl.CommandServiceImpl$$anonfun$bindCommandHandler$2$$anonfun$2.apply(CommandServiceImpl.scala:149)[61:org.totalgrid.reef.service-client:0.4.0]
        at org.totalgrid.reef.client.sapi.rpc.impl.CommandServiceImpl$$anonfun$bindCommandHandler$2$$anonfun$2.apply(CommandServiceImpl.scala:149)[61:org.totalgrid.reef.service-client:0.4.0]
        at net.agileautomata.executor4s.Future$WrappedFuture.await(Future.scala:52)[53:net.agile-automata.executor4s.2.9.0-1:0.1.9.RC3]
        at org.totalgrid.reef.client.sapi.rpc.impl.CommandServiceImpl$$anonfun$bindCommandHandler$2.apply(CommandServiceImpl.scala:149)[61:org.totalgrid.reef.service-client:0.4.0]
        at org.totalgrid.reef.client.sapi.rpc.impl.CommandServiceImpl$$anonfun$bindCommandHandler$2.apply(CommandServiceImpl.scala:143)[61:org.totalgrid.reef.service-client:0.4.0]
        at org.totalgrid.reef.client.sapi.client.rest.impl.DefaultAnnotatedOperations.opWithFuture(DefaultAnnotatedOperations.scala:54)[60:org.totalgrid.reef.client:0.4.0]
        at org.totalgrid.reef.client.sapi.client.rest.impl.DefaultAnnotatedOperations.operation(DefaultAnnotatedOperations.scala:61)[60:org.totalgrid.reef.client:0.4.0]
        at org.totalgrid.reef.client.sapi.rpc.impl.CommandServiceImpl$class.bindCommandHandler(CommandServiceImpl.scala:143)[61:org.totalgrid.reef.service-client:0.4.0]
        at org.totalgrid.reef.client.sapi.rpc.impl.AllScadaServiceWrapper.bindCommandHandler(AllScadaServiceImpl.scala:45)[61:org.totalgrid.reef.service-client:0.4.0]
        at org.totalgrid.reef.client.service.impl.CommandServiceJavaShim$class.bindCommandHandler(CommandServiceJavaShim.scala:40)[61:org.totalgrid.reef.service-client:0.4.0]
        at org.totalgrid.reef.client.service.impl.AllScadaServiceJavaShimWrapper.bindCommandHandler(AllScadaServiceJavaShim.scala:48)[61:org.totalgrid.reef.service-client:0.4.0]

Adam Todorski

unread,
Mar 12, 2012, 7:02:08 PM3/12/12
to reef-...@googlegroups.com
The form took my post before I was finished...anyway, not much more to say, other than that I feel like I'm doing something fundamentally wrong but I can't put my finger on what.  Any thoughts would be much appreciated!

Sam Hendley

unread,
Mar 12, 2012, 7:09:54 PM3/12/12
to reef-...@googlegroups.com
Double check where you are getting the endpoint UUID. Make sure it is actually of type Endpoint. This error is indicative of it looking for a particular endpoint with the given uuid and not finding it. I would have expected that you get a better error message like: 

"Couldn't find endpoint connection for endpoint: UUID-UUID-UUID -  Expected a response list of size 1, but got a list of size: 0"

You didn't get the error I expected because the bindCommandHandler is actually a "multi step" request and our error message handling apparently doesn't work with the multi step requests. I am creating a ticket for a better error message for these types of calls.

My guess is that there is a bit of misunderstanding about what the Endpoint is. An Endpoint is an "object" that is responsible for producing measurements and responding to command requests for a set of Points and Commands. Each Command is not an Endpoint itself. You can back track from a command to its endpoint using: 

CommandService commandService;
Command c = commandService.getCommandByName("MyCommand");
ReefUUID endpointUuid = c.getEndpoint().getUuid();

Let me know if that helps.

Sam

Sam Hendley

unread,
Mar 12, 2012, 7:19:21 PM3/12/12
to reef-...@googlegroups.com
Ticket for the error message:


Also I re-read your question when I was making the ticket and I think I may have totally missed the real intent of your question. Can you explain what you are trying to do when the setpoint is received? That would help me give you a good "holistic" solution that should save you going to down too many rabbit holes.

Thanks

Sam

Adam Todorski

unread,
Mar 12, 2012, 7:25:37 PM3/12/12
to reef-...@googlegroups.com
Thanks, Sam.  I think I see my problem: the name I'm using to identify measurements is not the same as the endpoint which I care about, so using the same name in both situations was the issue.  Thank you for the clarification.

As far as my situation from a higher level, I'm using reef to interface with an external system that talks DNP3.  I need to publish measurements to it and to act upon setpoints from it, so I made a bundle to do this and configured an endpoint as a dnp3-slave to feed the information in and out through.

Thank you again for your help!

Adam
Reply all
Reply to author
Forward
0 new messages