MaxFerretti / XPlaneConnector

Read data and send commands to XPlane via UDP
MIT License
65 stars 23 forks source link

Adding custom datarefs #3

Closed akikettu closed 5 years ago

akikettu commented 5 years ago

Hi,

There's quite many datarefs not included as DataRefElement in connector. Example I'd like to access Zibo 737-800 datarefs (I think they are mostly shared with X-Plane 11 Default 737) like laminar/B738/engine/starter1_pos.

It is endless job to include all datarefs of all current and future x-plane mods so could you include some easy way to define those "custom" datarefs (including data type and size) so users of library like me can add them as needed?

Thanks for great library!

MaxFerretti commented 5 years ago

Hello, thank you for your feedback, it's very appreciated. You can add custom datarefs using the DataRefElement class and then subscribing to it on the connector.

var myDR = new DataRefElement
                {
                    DataRef = "laminar/B738/engine/starter1_pos",
                    Frequency = 5
                };

connector.Subscribe(myDR,` myDR.Frequency, (element, value) => { /* Your code */});

You can do the same with String data type just using StringDataRefElement.

Let me know if that was helpful, if not and you need some specific change I can add it to the library.

Have a nice flight

akikettu commented 5 years ago

Thanks for reply!

After experimenting I ended up to make copy of DataRefs and Commands classes and define my own DataRefs there so they are easier to use than strings but they are on separate files so if there's updates for XPlaneConnector in future changes wouldn't be overwritten.

So not changes needed this time :)