locked
How to create a custom DSSP operation based on a Query? RRS feed

  • Question

  • Hello,

     

    I am trying to create a custom DSSP query based on the existing Query operation. Here is a snippet from the _state:

     

    Code Snippet

    public class MyState

    {

    private double _frequency;

    [DataMember]

    public double Frequency

    {

    get { return _frequency; }

    set { _frequency = value; }

    }

    }

     

     

     

    Now I want to create a custom service operation, which I've properly added to the main  port set.  Here is the code for the operation:

     

    Code Snippet

    public class GetFrequency : Query<GetFrequencyQuery, PortSet< XXXXX, Fault>>

    {

    }

    [DataContract]

    public class GetFrequencyQuery

    {

    }

     

     

    What do I put as the successful operation return type (where the XXXXX's are located)?  This location specifies the type returned for a successful GetFreqency operation, correct?

     

    I tried putting a 'double' as the type, but I get a Robotics Studio error.

     

    Thanks,
    Scott

     

     

    Monday, June 30, 2008 3:21 AM

Answers

  • Hi Scott,

     

    One way is to also create a response object as follows:

     

    Code Snippet

    public class GetFrequency : Query<GetFrequencyQuery, PortSet<FrequencyResponse, Fault>>

    {

    }

    [DataContract]

    public class GetFrequencyQuery

    {

    }

    [DataContract]

    public class FrequencyResponse

    {

    [DataMember]

    public double frequency;

    }

     

     

    Then, in the handler for GetFrequencyQuery, simply do:

     

    Code Snippet

    public void GetFrequencyQueryHandler(GetFrequencyQuery query)

    {

    FrequencyResponse response = new FrequencyResponse();

    response.frequency = state.Frequency;

    query.ResponsePort.Post(response);

    }

     

     

    This is at least how I would handle it... maybe there is a better way.

     

    -Don

    Monday, June 30, 2008 3:52 AM

All replies

  • Hi Scott,

     

    One way is to also create a response object as follows:

     

    Code Snippet

    public class GetFrequency : Query<GetFrequencyQuery, PortSet<FrequencyResponse, Fault>>

    {

    }

    [DataContract]

    public class GetFrequencyQuery

    {

    }

    [DataContract]

    public class FrequencyResponse

    {

    [DataMember]

    public double frequency;

    }

     

     

    Then, in the handler for GetFrequencyQuery, simply do:

     

    Code Snippet

    public void GetFrequencyQueryHandler(GetFrequencyQuery query)

    {

    FrequencyResponse response = new FrequencyResponse();

    response.frequency = state.Frequency;

    query.ResponsePort.Post(response);

    }

     

     

    This is at least how I would handle it... maybe there is a better way.

     

    -Don

    Monday, June 30, 2008 3:52 AM
  • I don't mean to hijack this thread, but I think this is a related question. Is there a tutorial or an article out there that talks about Query and all the other message types that DSSP supports, talks about the Response Type, and what each is really supposed to do? like what is the difference between Lookup and Query?

     

    Thanks

     

    Monday, June 30, 2008 10:29 AM
  • Don,

     

    That worked, thank you.

     

    Good luck at AUVSI.

     

    --Scott

     

    Tuesday, July 1, 2008 1:18 AM
  • Hi Davy,

     

    You can read the full definition of DSSP here:

    http://download.microsoft.com/download/5/6/B/56B49917-65E8-494A-BB8C-3D49850DAAC1/DSSP.pdf

     

    I don't know if that is what you want. It is not a tutorial.

     

    Trevor

     

    Tuesday, July 1, 2008 6:44 AM