/// <summary>
        /// Processes the response to the InstrumentInfo command.
        /// </summary>
        /// <param name="instrumentInfoResponse">Command response data.</param>
        private void ProcessInstrumentInfoResponse(XElement instrumentInfoResponse)
        {
            //Expected response
            //<InstrumentInfo>
            //  <field Label="...">...</field>
            //  ...
            //</InstrumentInfo>

            using (InstrumentInfo.AcquireLock())
            {
                InstrumentInfo.Clear();

                foreach (var fieldElement in instrumentInfoResponse.Elements("field", StringComparison.InvariantCultureIgnoreCase))
                {
                    var label = FindAttribute(fieldElement, "Label").Value;
                    InstrumentInfo.Add(new InstrumentInfoElement(label, fieldElement.Value));

                    if (string.Compare(label, "Options", true) == 0)
                    {
                        Options = fieldElement.Value;
                    }
                    else if (string.Compare(label, "Family", true) == 0)
                    {
                        Family = fieldElement.Value;
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Processes the response to the InstrumentInfo command.
        /// </summary>
        /// <param name="instrumentInfoResponse">Command response data.</param>
        private void ProcessInstrumentInfoResponse(XElement instrumentInfoResponse)
        {
            //Expected response
            //<InstrumentInfo>
            //  <field Label="...">...</field>
            //  ...
            //</InstrumentInfo>

            using (InstrumentInfo.AcquireLock())
            {
                InstrumentInfo.Clear();

                foreach (var fieldElement in instrumentInfoResponse.Elements("field"))
                {
                    InstrumentInfo.Add(new InstrumentInfoElement(fieldElement.Attribute("label").Value, fieldElement.Value));

                    if (fieldElement.Attribute("label").Value == "Options")
                    {
                        Options = fieldElement.Value;
                    }
                }
            }
        }
        /// <summary>
        /// Called when a property change notification is raised on this view model. This view model
        /// uses this method to monitor when the Connected property is changed. This logic could have
        /// been placed in the Connected property setter, but putting it here keeps the property setter simple.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event arguments.</param>
        void ConnectionViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "Connected")
            {
                LoggedOn    = false;
                LogOnResult = String.Empty;

                if (Connected)
                {
                    //We have become connected, so send a to get general information about
                    //the instrument we have connected to. These commands can be executed without
                    //first executing a Logon command.
                    SendData(new SendDataEventArgs(_versionCommandDocument.ToString(), this));
                    SendData(new SendDataEventArgs(_supportedCulturesCommandDocument.ToString(), this));
                    SendData(new SendDataEventArgs(_instrumentInfoCommandDocument.ToString(), this));
                }
                else
                {
                    //We have become disconnected, so clear out our data.
                    InstrumentVersion = String.Empty;
                    ProtocolVersion   = String.Empty;
                    SelectedLanguage  = null;
                    Options           = String.Empty;
                    Family            = string.Empty;

                    using (SupportedCultures.AcquireLock())
                    {
                        SupportedCultures.Clear();
                    }

                    using (InstrumentInfo.AcquireLock())
                    {
                        InstrumentInfo.Clear();
                    }
                }
            }
        }