Ejemplo n.º 1
0
        public GuiAnalyzerSingleFigure(uint id, _PlcAgent.Analyzer.Analyzer analyzer)
            : base(analyzer)
        {
            InitializeComponent();

            BrushComboBox.ItemsSource = _colorsList;
            BrushComboBox.SelectedItem = Brushes.Green;
            BrushComboBox.DataContext = this;

            Analyzer.CommunicationInterfaceHandler.OnInterfaceUpdatedDelegate += OnInterfaceUpdated;
            OnInterfaceUpdated();

            _analyzerChannel = Analyzer.AnalyzerChannels.GetChannel(id);
            ChannelGroupBox.Header = "Channel " + _analyzerChannel.Id;

            PlotArea.Dispatcher.BeginInvoke((new Action(
                () => PlotArea.DataContext = new DataMainViewModel())));

            if (_analyzerChannel.AnalyzerObservableVariable != null)
            {
                UpdateControls(this, new PropertyChangedEventArgs("CommunicationInterfaceVariable"));
                UpdateControls(this, new PropertyChangedEventArgs("Brush"));
                UpdateControls(this, new PropertyChangedEventArgs("Unit"));
                _analyzerChannel.AnalyzerObservableVariable.PropertyChanged += UpdateControls;

                PlotArea.Dispatcher.BeginInvoke((new Action(
                () => PlotArea.DataContext = _analyzerChannel.AnalyzerObservableVariable.MainViewModelClone)));
            }

            _save = true;
        }
Ejemplo n.º 2
0
        public void RetriveConfiguration()
        {
            Children.Clear();

            foreach (
                var channelStrings in
                    AnalyzerSetupFile.Channels[Analyzer.Header.Id].Where(channel => channel != null)
                        .Select(channel => channel.Split('%')))
            {
                if (channelStrings[1] != "Empty")
                {
                    var newChannel = new AnalyzerChannel(Convert.ToUInt32(channelStrings[0]), Analyzer);
                    var variable = Analyzer.CommunicationInterfaceHandler.ReadInterfaceComposite.ReturnVariable(
                        channelStrings[1]);

                    if (variable != null)
                    {
                        newChannel.AnalyzerObservableVariable = new AnalyzerObservableVariable(Analyzer, variable)
                        {
                            Name = channelStrings[2],
                            Unit = channelStrings[4],
                            Brush = (Brush) new BrushConverter().ConvertFromString(channelStrings[5]),
                        };
                    }
                    Children.Add(newChannel);
                }
                else
                {
                    Children.Add(new AnalyzerChannel(Convert.ToUInt32(channelStrings[0]), Analyzer));
                }
            }

            StoreConfiguration();
            if (OnChannelListModified != null) OnChannelListModified();
        }
Ejemplo n.º 3
0
 public void Remove(AnalyzerChannel analyzerChannel)
 {
     Children.Remove(analyzerChannel);
     StoreConfiguration();
     if (OnChannelListModified != null) OnChannelListModified();
 }
Ejemplo n.º 4
0
        public void RemoveChannel(AnalyzerChannel analyzerChannel)
        {
            AnalyzerChannels.Remove(analyzerChannel);

            AnalyzerSetupFile.NumberOfChannels[Header.Id] -= 1;
            AnalyzerSetupFile.Save();
        }