Example #1
0
        public OneTimeAccessModel(
            Interfaces.IConnection connector,
            Interfaces.IOneTimeAccessOperator otaOperator
            )
        {
            this._itemsToRead = new ObservableCollection <VariableInfo>();
            this.otaOperator  = otaOperator;

            BindingOperations.EnableCollectionSynchronization(_itemsToRead, new object());

            DeleteOneTimeAccessItemsCommand = new Commands.DelegateCommand(
                (param) => { DeleteOneTimeAccessItems(); },
                (param) => { return(OneTimeAccessItems.Count > 0); });

            ReadCommand = new Commands.DelegateCommand(
                (param) => { OneTimeRead(); },
                (param) => { return(connector.Connected && OneTimeAccessItems.Count > 0); });

            WriteCommand = new Commands.DelegateCommand(
                (param) => { GroupWrite(this._itemsToRead); },
                (param) => { return(connector.Connected && OneTimeAccessItems.Count > 0); });

            connector.ObserveProperty(x => x.Connected).Subscribe(c => { if (!c)
                                                                         {
                                                                             Close();
                                                                         }
                                                                  });
        }
Example #2
0
        public MainWindowViewModel(Interfaces.IConnection client)
        {
            this.client = client;

            ClosingCommand = new Commands.DelegateCommand(
                (param) => { client.Close(); },
                (param) => true);

            SelectedIndexForTabControl = 1;
        }
Example #3
0
        public NodeInfoDataGridModel(
            Interfaces.IConnection connector,
            Interfaces.INodeInfoGetter client)
        {
            this.client    = client;
            this.connector = connector;

            this.NodeInfoList = new ObservableCollection <NodeInfo>();

            this.connector.ObserveProperty(x => x.Connected).Subscribe(c => { if (!c)
                                                                              {
                                                                                  Close();
                                                                              }
                                                                       });
        }
Example #4
0
        public ConnectionModel(Interfaces.IConnection client)
        {
            this.client = client;

            this.client.ObserveProperty(x => x.Connected).Subscribe(c => {
                if (c)
                {
                    ConnectButtonContent = "Disconnect";
                }
                else
                {
                    ConnectButtonContent = "Connect";
                }
            });

            this.ConnectCommand = new Commands.AsyncCommand(async(param) =>
            {
                await CreateSession(null);
            });
        }
Example #5
0
        public SubscriptionModel(
            Interfaces.IConnection connector,
            Interfaces.ISubscriptionOperatable subscriptionOperator)
        {
            this.subscriptionOperator = subscriptionOperator;

            BindingOperations.EnableCollectionSynchronization(monitoredItems, new object());

            subscriptionOperator.SessionNotification -= Session_Notificaiton;
            subscriptionOperator.SessionNotification += Session_Notificaiton;

            DeleteMonitoredItemsCommand = new Commands.DelegateCommand(
                (param) => { DeleteMonitoredItems(); },
                (param) => { return(connector.Connected && monitoredItems.Count > 0); });

            connector.ObserveProperty(x => x.Connected).Subscribe(c => { if (!c)
                                                                         {
                                                                             Close();
                                                                         }
                                                                  });
        }
Example #6
0
        public NodeTreeModel(
            Interfaces.IConnection connector,
            Interfaces.IReference references,
            Interfaces.ISubscriptionModel subscriptionM,
            Interfaces.IOneTimeAccessModel oneTimeAccessM)
        {
            this.connector  = connector;
            this.references = references;

            ReloadCommand = new Commands.DelegateCommand(
                (param) => { ForceUpdate(); },
                (param) => connector.Connected);

            MouseDoubleClickedCommand = new DelegateCommand <IList>((items) =>
            {
                subscriptionM.AddToSubscription(items);
                ChangeSelectedIndexForTabContorol(0);
            }, (param) => true);

            AddToReadWriteCommand = new Commands.DelegateCommand(
                (param) => {
                oneTimeAccessM.AddToReadWrite((IList)param);
                ChangeSelectedIndexForTabContorol(1);
            },
                (param) => connector.Connected);

            NodeSelectedCommand = new Commands.DelegateCommand(
                (param) => { }, //nodeInfoDataGrid.Update((VariableNode)param); },
                (param) => true);

            UpdateVariableNodeListCommand = new Commands.DelegateCommand(
                (param) => { UpdateVariableNodes((Interfaces.IReference)param); },
                (param) => true);

            this.connector.ObserveProperty(x => x.Connected).Subscribe(c => Update(c));

            Initialize();
        }
Example #7
0
        public ScriptViewModel(Interfaces.IConnection client)
        {
            Script = new TextDocument();

            log = new LogStream();

            log.PropertyChanged += Log_PropertyChanged;

            this.engine = new ScriptEngine.V8Engine((Client)client);

            RunCommand = new DelegateCommand <string>((body) =>
            {
                Task.Run(() =>
                {
                    IsRunning = true;

                    this.tokenSource = new CancellationTokenSource();

                    var cancel = tokenSource.Token;

                    Task.Run(() => {
                        do
                        {
                            engine.Run(body, log, cancel);
                        } while (_isRepeat && !cancel.IsCancellationRequested);
                        IsRunning = false;
                    }, cancel);
                });
            });

            StopCommand = new DelegateCommand(() =>
            {
                engine.Stop();
                this.tokenSource.Cancel();
                IsRunning = false;
            });

            RepeatCommand = new DelegateCommand(() =>
            {
                IsRepeat = !_isRepeat;
            });

            LoadCommand = new DelegateCommand(() =>
            {
                using (var ofd = new OpenFileDialog())
                {
                    ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                    ofd.Filter           = "Javascript files (*.js)|*.js|All files (*.*)|*.*";
                    ofd.FilterIndex      = 1;
                    ofd.RestoreDirectory = true;

                    if (ofd.ShowDialog() == DialogResult.OK)
                    {
                        Script = new TextDocument(File.ReadAllText(ofd.FileName, System.Text.Encoding.UTF8));
                    }
                }
            });

            ClearOutputCommand = new DelegateCommand(() =>
            {
                ScriptOutput.Clear();
            });
        }
Example #8
0
 public DALManager()
 {
     Connection = new ConnectionSQL();
 }