|
| 1 | +package rti // import "github.com/rticommunity/rticonnextdds-connector-go" |
| 2 | + |
| 3 | +Package rti implements functions of RTI Connector for Connext DDS in Go |
| 4 | + |
| 5 | +# Package rti implements functions of RTI Connector for Connext DDS in Go |
| 6 | + |
| 7 | +# Package rti implements functions of RTI Connector for Connext DDS in Go |
| 8 | + |
| 9 | +# Package rti implements functions of RTI Connector for Connext DDS in Go |
| 10 | + |
| 11 | +# Package rti implements functions of RTI Connector for Connext DDS in Go |
| 12 | + |
| 13 | +Package rti implements functions of RTI Connector for Connext DDS in Go |
| 14 | + |
| 15 | +CONSTANTS |
| 16 | + |
| 17 | +const ( |
| 18 | + // DDSRetCodeNoData is a Return Code from CGO for no data return |
| 19 | + DDSRetCodeNoData = 11 |
| 20 | + // DDSRetCodeTimeout is a Return Code from CGO for timeout code |
| 21 | + DDSRetCodeTimeout = 10 |
| 22 | + // DDSRetCodeOK is a Return Code from CGO for good state |
| 23 | + DDSRetCodeOK = 0 |
| 24 | +) |
| 25 | + |
| 26 | +VARIABLES |
| 27 | + |
| 28 | +var ErrNoData = errors.New("DDS Exception: No Data") |
| 29 | + ErrNoData is returned when there is no data available in the DDS layer |
| 30 | + |
| 31 | +var ErrTimeout = errors.New("DDS Exception: Timeout") |
| 32 | + ErrTimeout is returned when there is a timeout in the DDS layer |
| 33 | + |
| 34 | + |
| 35 | +TYPES |
| 36 | + |
| 37 | +type Connector struct { |
| 38 | + Inputs []Input |
| 39 | + Outputs []Output |
| 40 | + // Has unexported fields. |
| 41 | +} |
| 42 | + Connector is a container managing DDS inputs and outputs |
| 43 | + |
| 44 | +func NewConnector(configName, url string) (*Connector, error) |
| 45 | + NewConnector is a constructor of Connector. |
| 46 | + |
| 47 | + url is the location of XML documents in URL format. For example: |
| 48 | + |
| 49 | + File specification: file:///usr/local/default_dds.xml |
| 50 | + String specification: str://"<dds><qos_library>…</qos_library></dds>" |
| 51 | + |
| 52 | + If you omit the URL schema name, Connector will assume a file name. |
| 53 | + For example: |
| 54 | + |
| 55 | + File Specification: /usr/local/default_dds.xml |
| 56 | + |
| 57 | +func (connector *Connector) Delete() error |
| 58 | + Delete is a destructor of Connector |
| 59 | + |
| 60 | +func (connector *Connector) GetInput(inputName string) (*Input, error) |
| 61 | + GetInput returns an input object |
| 62 | + |
| 63 | +func (connector *Connector) GetOutput(outputName string) (*Output, error) |
| 64 | + GetOutput returns an output object |
| 65 | + |
| 66 | +func (connector *Connector) Wait(timeoutMs int) error |
| 67 | + Wait is a function to block until data is available on an input |
| 68 | + |
| 69 | +type Identity struct { |
| 70 | + WriterGUID [16]byte `json:"writer_guid"` |
| 71 | + SequenceNumber int `json:"sequence_number"` |
| 72 | +} |
| 73 | + Identity is the structure for identifying |
| 74 | + |
| 75 | +type Infos struct { |
| 76 | + // Has unexported fields. |
| 77 | +} |
| 78 | + Infos is a sequence of info samples used by an input to read DDS meta data |
| 79 | + |
| 80 | +func (infos *Infos) GetIdentity(index int) (Identity, error) |
| 81 | + GetIdentity is a function to get the identity of a writer that sent the |
| 82 | + sample |
| 83 | + |
| 84 | +func (infos *Infos) GetIdentityJSON(index int) (string, error) |
| 85 | + GetIdentityJSON is a function to get the identity of a writer in JSON |
| 86 | + |
| 87 | +func (infos *Infos) GetInstanceState(index int) (string, error) |
| 88 | + GetInstanceState is a function used to get a instance state in string (one |
| 89 | + of "ALIVE", "NOT_ALIVE_DISPOSED" or "NOT_ALIVE_NO_WRITERS"). |
| 90 | + |
| 91 | +func (infos *Infos) GetLength() (int, error) |
| 92 | + GetLength is a function to return the length of the |
| 93 | + |
| 94 | +func (infos *Infos) GetReceptionTimestamp(index int) (int64, error) |
| 95 | + GetReceptionTimestamp is a function to get the reception timestamp of a |
| 96 | + sample |
| 97 | + |
| 98 | +func (infos *Infos) GetRelatedIdentity(index int) (Identity, error) |
| 99 | + GetRelatedIdentity is a function used for request-reply communications. |
| 100 | + |
| 101 | +func (infos *Infos) GetRelatedIdentityJSON(index int) (string, error) |
| 102 | + GetRelatedIdentityJSON is a function used for get related identity in JSON. |
| 103 | + |
| 104 | +func (infos *Infos) GetSampleState(index int) (string, error) |
| 105 | + GetSampleState is a function used to get a sample state in string (either |
| 106 | + "READ" or "NOT_READ"). |
| 107 | + |
| 108 | +func (infos *Infos) GetSourceTimestamp(index int) (int64, error) |
| 109 | + GetSourceTimestamp is a function to get the source timestamp of a sample |
| 110 | + |
| 111 | +func (infos *Infos) GetViewState(index int) (string, error) |
| 112 | + GetViewState is a function used to get a view state in string (either "NEW" |
| 113 | + or "NOT NEW"). |
| 114 | + |
| 115 | +func (infos *Infos) IsValid(index int) (bool, error) |
| 116 | + IsValid is a function to check validity of the element and return a boolean |
| 117 | + |
| 118 | +type Input struct { |
| 119 | + Samples *Samples |
| 120 | + Infos *Infos |
| 121 | + // Has unexported fields. |
| 122 | +} |
| 123 | + Input subscribes to DDS data |
| 124 | + |
| 125 | +func (input *Input) GetMatchedPublications() (string, error) |
| 126 | + Note that Connector Outputs are automatically assigned a name from the |
| 127 | + *data_writer name* in the XML configuration. |
| 128 | + |
| 129 | +func (input *Input) Read() error |
| 130 | + Read is a function to read DDS samples from the DDS DataReader and allow |
| 131 | + access them via the Connector Samples. The Read function does not remove DDS |
| 132 | + samples from the DDS DataReader's receive queue. |
| 133 | + |
| 134 | +func (input *Input) Take() error |
| 135 | + Take is a function to take DDS samples from the DDS DataReader and allow |
| 136 | + access them via the Connector Samples. The Take function removes DDS samples |
| 137 | + from the DDS DataReader's receive queue. |
| 138 | + |
| 139 | +func (input *Input) WaitForPublications(timeoutMs int) (int, error) |
| 140 | + Waits until this input matches or unmatches a compatible DDS subscription. |
| 141 | + If the operation times out, it will raise :class:`TimeoutError`. Parameters: |
| 142 | + |
| 143 | + timeout: The maximum time to wait in milliseconds. Set -1 if you want infinite. |
| 144 | + |
| 145 | + Return: The change in the current number of matched outputs. If a |
| 146 | + positive number is returned, the input has matched with new publishers. |
| 147 | + If a negative number is returned the input has unmatched from an output. |
| 148 | + It is possible for multiple matches and/or unmatches to be returned (e.g., |
| 149 | + 0 could be returned, indicating that the input matched the same number of |
| 150 | + writers as it unmatched). |
| 151 | + |
| 152 | +type Instance struct { |
| 153 | + // Has unexported fields. |
| 154 | +} |
| 155 | + Instance is used by an output to write DDS data |
| 156 | + |
| 157 | +func (instance *Instance) Set(v interface{}) error |
| 158 | + Set is a function that consumes an interface of multiple samples with |
| 159 | + different types and value TODO - think about a new name for this a function |
| 160 | + (e.g. SetType, SetFromType, FromType) |
| 161 | + |
| 162 | +func (instance *Instance) SetBoolean(fieldName string, value bool) error |
| 163 | + SetBoolean is a function to set boolean to a fieldname of the samples |
| 164 | + |
| 165 | +func (instance *Instance) SetByte(fieldName string, value byte) error |
| 166 | + SetByte is a function to set a byte to a fieldname of the samples |
| 167 | + |
| 168 | +func (instance *Instance) SetFloat32(fieldName string, value float32) error |
| 169 | + SetFloat32 is a function to set a value of type float32 into samples |
| 170 | + |
| 171 | +func (instance *Instance) SetFloat64(fieldName string, value float64) error |
| 172 | + SetFloat64 is a function to set a value of type float64 into samples |
| 173 | + |
| 174 | +func (instance *Instance) SetInt(fieldName string, value int) error |
| 175 | + SetInt is a function to set a value of type int into samples |
| 176 | + |
| 177 | +func (instance *Instance) SetInt16(fieldName string, value int16) error |
| 178 | + SetInt16 is a function to set a value of type int16 into samples |
| 179 | + |
| 180 | +func (instance *Instance) SetInt32(fieldName string, value int32) error |
| 181 | + SetInt32 is a function to set a value of type int32 into samples |
| 182 | + |
| 183 | +func (instance *Instance) SetInt64(fieldName string, value int64) error |
| 184 | + SetInt64 is a function to set a value of type int64 into samples |
| 185 | + |
| 186 | +func (instance *Instance) SetInt8(fieldName string, value int8) error |
| 187 | + SetInt8 is a function to set a value of type int8 into samples |
| 188 | + |
| 189 | +func (instance *Instance) SetJSON(blob []byte) error |
| 190 | + SetJSON is a function to set JSON string in the form of slice of bytes into |
| 191 | + Instance |
| 192 | + |
| 193 | +func (instance *Instance) SetRune(fieldName string, value rune) error |
| 194 | + SetRune is a function to set rune to a fieldname of the samples |
| 195 | + |
| 196 | +func (instance *Instance) SetString(fieldName, value string) error |
| 197 | + SetString is a function that set a string to a fieldname of the samples |
| 198 | + |
| 199 | +func (instance *Instance) SetUint(fieldName string, value uint) error |
| 200 | + SetUint is a function to set a value of type uint into samples |
| 201 | + |
| 202 | +func (instance *Instance) SetUint16(fieldName string, value uint16) error |
| 203 | + SetUint16 is a function to set a value of type uint16 into samples |
| 204 | + |
| 205 | +func (instance *Instance) SetUint32(fieldName string, value uint32) error |
| 206 | + SetUint32 is a function to set a value of type uint32 into samples |
| 207 | + |
| 208 | +func (instance *Instance) SetUint64(fieldName string, value uint64) error |
| 209 | + SetUint64 is a function to set a value of type uint64 into samples |
| 210 | + |
| 211 | +func (instance *Instance) SetUint8(fieldName string, value uint8) error |
| 212 | + SetUint8 is a function to set a value of type uint8 into samples |
| 213 | + |
| 214 | +type Output struct { |
| 215 | + Instance *Instance |
| 216 | + // Has unexported fields. |
| 217 | +} |
| 218 | + Output publishes DDS data |
| 219 | + |
| 220 | +func (output *Output) ClearMembers() error |
| 221 | + ClearMembers is a function to initialize a DDS data instance in an output |
| 222 | + |
| 223 | +func (output *Output) GetMatchedSubscriptions() (string, error) |
| 224 | + Note that Connector Inputs are automatically assigned a name from the |
| 225 | + *data_reader name* in the XML configuration. |
| 226 | + |
| 227 | +func (output *Output) WaitForSubscriptions(timeoutMs int) (int, error) |
| 228 | + Return: The change in the current number of matched outputs. If a |
| 229 | + positive number is returned, the input has matched with new publishers. |
| 230 | + If a negative number is returned the input has unmatched from an output. |
| 231 | + It is possible for multiple matches and/or unmatches to be returned (e.g., |
| 232 | + 0 could be returned, indicating that the input matched the same number of |
| 233 | + writers as it unmatched). |
| 234 | + |
| 235 | +func (output *Output) Write() error |
| 236 | + Write is a function to write a DDS data instance in an output |
| 237 | + |
| 238 | +func (output *Output) WriteWithParams(jsonStr string) error |
| 239 | + WriteWithParams is a function to write a DDS data instance with parameters |
| 240 | + The supported parameters are: action: One of "write" (default), |
| 241 | + "dispose" or "unregister" source_timestamp: The source timestamp, an |
| 242 | + integer representing the total number of nanoseconds identity: A dictionary |
| 243 | + containing the keys "writer_guid" (a list of 16 bytes) and "sequence_number" |
| 244 | + (an integer) that uniquely identifies this sample. related_sample_identity: |
| 245 | + Used for request-reply communications. It has the same format as "identity" |
| 246 | + For example:: output.Write( |
| 247 | + |
| 248 | + identity={"writer_guid":[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], "sequence_number":1}, |
| 249 | + timestamp=1000000000) |
| 250 | + |
| 251 | +type SampleHandler func(samples *Samples, infos *Infos) |
| 252 | + SampleHandler is an User defined function type that takes in pointers of |
| 253 | + Samples and Infos and will handle received samples. |
| 254 | + |
| 255 | +type Samples struct { |
| 256 | + // Has unexported fields. |
| 257 | +} |
| 258 | + Samples is a sequence of data samples used by an input to read DDS data |
| 259 | + |
| 260 | +func (samples *Samples) Get(index int, v interface{}) error |
| 261 | + Get is a function to retrieve all the information of the samples and put it |
| 262 | + into an interface |
| 263 | + |
| 264 | +func (samples *Samples) GetBoolean(index int, fieldName string) (bool, error) |
| 265 | + GetBoolean is a function to retrieve a value of type boolean from the |
| 266 | + samples |
| 267 | + |
| 268 | +func (samples *Samples) GetByte(index int, fieldName string) (byte, error) |
| 269 | + GetByte is a function to retrieve a value of type byte from the samples |
| 270 | + |
| 271 | +func (samples *Samples) GetFloat32(index int, fieldName string) (float32, error) |
| 272 | + GetFloat32 is a function to retrieve a value of type float32 from the |
| 273 | + samples |
| 274 | + |
| 275 | +func (samples *Samples) GetFloat64(index int, fieldName string) (float64, error) |
| 276 | + GetFloat64 is a function to retrieve a value of type float64 from the |
| 277 | + samples |
| 278 | + |
| 279 | +func (samples *Samples) GetInt(index int, fieldName string) (int, error) |
| 280 | + GetInt is a function to retrieve a value of type int from the samples |
| 281 | + |
| 282 | +func (samples *Samples) GetInt16(index int, fieldName string) (int16, error) |
| 283 | + GetInt16 is a function to retrieve a value of type int16 from the samples |
| 284 | + |
| 285 | +func (samples *Samples) GetInt32(index int, fieldName string) (int32, error) |
| 286 | + GetInt32 is a function to retrieve a value of type int32 from the samples |
| 287 | + |
| 288 | +func (samples *Samples) GetInt64(index int, fieldName string) (int64, error) |
| 289 | + GetInt64 is a function to retrieve a value of type int64 from the samples |
| 290 | + |
| 291 | +func (samples *Samples) GetInt8(index int, fieldName string) (int8, error) |
| 292 | + GetInt8 is a function to retrieve a value of type int8 from the samples |
| 293 | + |
| 294 | +func (samples *Samples) GetJSON(index int) ([]byte, error) |
| 295 | + GetJSON is a function to retrieve a slice of bytes of a JSON string from the |
| 296 | + samples |
| 297 | + |
| 298 | +func (samples *Samples) GetLength() (int, error) |
| 299 | + GetLength is a function to get the number of samples |
| 300 | + |
| 301 | +func (samples *Samples) GetRune(index int, fieldName string) (rune, error) |
| 302 | + GetRune is a function to retrieve a value of type rune from the samples |
| 303 | + |
| 304 | +func (samples *Samples) GetString(index int, fieldName string) (string, error) |
| 305 | + GetString is a function to retrieve a value of type string from the samples |
| 306 | + |
| 307 | +func (samples *Samples) GetUint(index int, fieldName string) (uint, error) |
| 308 | + GetUint is a function to retrieve a value of type uint from the samples |
| 309 | + |
| 310 | +func (samples *Samples) GetUint16(index int, fieldName string) (uint16, error) |
| 311 | + GetUint16 is a function to retrieve a value of type uint16 from the samples |
| 312 | + |
| 313 | +func (samples *Samples) GetUint32(index int, fieldName string) (uint32, error) |
| 314 | + GetUint32 is a function to retrieve a value of type uint32 from the samples |
| 315 | + |
| 316 | +func (samples *Samples) GetUint64(index int, fieldName string) (uint64, error) |
| 317 | + GetUint64 is a function to retrieve a value of type uint64 from the samples |
| 318 | + |
| 319 | +func (samples *Samples) GetUint8(index int, fieldName string) (uint8, error) |
| 320 | + GetUint8 is a function to retrieve a value of type uint8 from the samples |
| 321 | + |
0 commit comments