Andy B. Posted May 29, 2021 Report Share Posted May 29, 2021 Hi, I have a class called SingleStateToggle that has properties for offset, name (string that is self-assigned), AvaliableStates (0=off, 1=on, etc...), CurrentState (KeyValue pair of byte/string), and a few additional properties. When creating an instance of SingleStateToggle, the offset I assign doesn't change values when trying to find the KeyValue<byte, string> pair for the CurrentState. Here is some code to demonstrate my problem: SingleStateToggle: using FSUIPC; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace tfm.PMDG.PanelObjects { class SingleStateToggle: PanelObject { private Offset<byte> _offset; private PanelObjectType _type = PanelObjectType.SingleState; private Dictionary<byte, string> _availableStates = null; private KeyValuePair<byte, string> _currentState; public Dictionary<byte, string> AvailableStates { get => _availableStates; set => _availableStates = value; } public KeyValuePair<byte, string> CurrentState { // Try to retreive the KeyValue pair that matches offset.value. get { KeyValuePair<byte, string> item = new KeyValuePair<byte, string>(); foreach (KeyValuePair<byte, string> pair in this._availableStates) { if (This._offset.Value == pair.Key) { item = pair; break; } } return item; } // End Get } // End CurrentState. public override PanelObjectType Type => this._type; public Offset<byte> Offset { get => _offset; set => _offset = value; } public override string ToString() { return $"{this.Name}: {this.CurrentState.Value}"; } // End ToString. } // End SingleStateToggle. }// End namespace. In a class for the PMDG 777, I have the following code: using tfm.PMDG; using tfm.PMDG.PanelObjects; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace tfm { static class PMDG777 { public static PanelObject[] PanelControls { get => new PanelObject[] { new SingleStateToggle {Offset = Aircraft.pmdg777.BRAKES_ParkingBrakeLeverOn, Name = "Parking break", Verbosity = AircraftVerbosity.Low, PanelName = "Forward", PanelSection = "CDU", AvailableStates = new Dictionary<byte, string> { { 1, "on" }, { 0, "off" }, }, }, }; } } // End PMDG777 class. } // End namespace. After putting a breakpoint on SingleStateToggle.CurrentState, nothing happens except the foreach loop runs multiple times before dceiding that 0 is always the _offset.Value value. We do have the timer that runs the process method for all the offsets. Do you have any ideas why _offset.Value never changes? Link to comment Share on other sites More sharing options...
Andy B. Posted May 29, 2021 Author Report Share Posted May 29, 2021 You can ignore this post. I figured it out. I forgot to put PMDG777.RefreshData() in our main timer event. Everything works now. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now