Exemplo n.º 1
0
        public ServerController(ISoftwareController p_SoftwareController, AbstractViewFactory p_Factory, string p_MachineName, string p_ServerID)
        {
            m_SoftwareController = p_SoftwareController;

            m_ServerModel = new ServerModel();
            m_ServerView  = p_Factory.CreateServerView(this, p_ServerID);
            m_ServerModel.ModelChanged += new ModelChangeEventHandler(m_ServerView.ServerModelChange);

            m_MachineName = p_MachineName;
            m_ServerID    = p_ServerID;

            string[] ID_Spilts = p_ServerID.Split(new char[] { '.' });
            if (ID_Spilts[0] == "Veriteq")
            {
                VeriteqOPCServer = true;
                System.Console.WriteLine("Connect to a Veriteq Server\n");
            }

            m_DescriptionDictionary = new Dictionary <string, string>();
            m_UnitDictionary        = new Dictionary <string, string>();

            m_ItemAccessMutex = new Mutex();
            m_Server          = null;
            m_Group           = null;
        }
        public ServerController(ISoftwareController softwareController,
                                AbstractViewFactory factory,
                                string machineName,
                                string serverId)
        {
            _softwareController = softwareController;

            _serverView = factory.CreateServerView(this, serverId);

            if (_serverView is ServerTabUserControl serverTabUserControl)
            {
                serverTabUserControl.OnUpdateRate += (sender, args) =>
                {
                    Console.WriteLine(@"The new update rage is {0} millisecond", args.StateUpdateRate);
                    _group.UpdateRate = args.StateUpdateRate;
                }
            }
            ;

            _serverModel = new ServerModel();
            _serverModel.ModelChanged += _serverView.ServerModelChange;


            _machineName = machineName;
            _serverId    = serverId;

            _itemAccessMutex = new Mutex();
            _server          = null;
            _group           = null;
        }
        /// <summary>
        /// m_ConnectSrvBackgroundWorker.RunWorkerAsync
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void ConnectSrvBackgroundWorker_DoWork(object sender, DoWorkEventArgs eventArgs)
        {
            _isActionRunning = true;
            m_ConnectSrvBackgroundWorker.ReportProgress(0);
            _currentActionErrorCount = 0;

            _currentActionDescription = "Connection to an OPC server";

            DisplayMessageInReport("Connection to the server : " + SelectedServerId + "\n");
            DisplayMessageInActionStatus(_currentActionDescription);
            DisplayMessageInStateStatus("Running");

            try
            {
                m_ConnectSrvBackgroundWorker.ReportProgress(50);

                IServerView serverView = _softwareController.ConnectToOpcServer(SelectedMachineName, SelectedServerId);
                UpdateServerTabList(serverView.GetTabPage());
            }
            catch (Exception ex)
            {
                ErrorLog errorLog = ErrorLog.GetInstance();
                errorLog.WriteToErrorLog(ex.Message, ex.StackTrace, "Error during OPC server connection");

                _currentActionErrorCount++;

                DisplayMessageInReport(ex.Message + "\n");
            }

            m_ConnectSrvBackgroundWorker.ReportProgress(100);
        }
Exemplo n.º 4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="view">View que representa a tela de controle sobre o servidor de comunicação</param>
 public ServerPresenter(IServerView view)
 {
     _view              = view;
     wexServer          = new WexMultiAccessManager();
     UsuariosConectados = new List <UsuarioConectado>();
     TarefasEmEdicao    = new List <EdicaoTarefa>();
     ConfigurarEventosManager();
 }
        public int CloseServerTabView(IServerView serverView)
        {
            int index = m_ServersTabControl.TabPages.IndexOf(serverView.GetTabPage());

            m_ServersTabControl.SelectedIndex = m_ServersTabControl.SelectedIndex - 1;
            m_ServersTabControl.TabPages.Remove(serverView.GetTabPage());

            return(index);
        }
Exemplo n.º 6
0
 public void AddObserver(IServerView serverView)
 {
     if (ServerStaticMembers.Observers != null)
     {
         if (ServerStaticMembers.Observers.Contains(serverView) == false)
         {
             ServerStaticMembers.Observers.Add(serverView);
         }
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Initialize variables. If a manager isn't given, it uses the FileManager as
        /// DataManager. Also, if a view isn't provided, it starts the process in background.
        /// </summary>
        /// <param name="manager"></param>
        /// <param name="view"></param>
        /// <param name="port"></param>
        public ServerController(DataManager manager, IServerView view, int port = 4445)
        {
            this.ps = new ServerProcess();
            this.ps.clientHandler  = new ServerProcess.newClientHandler(incomingClient);
            this.ps.messageHandler = new ServerProcess.newMessageHandler(handleMessage);

            this.manager = (manager != null) ? manager : new FileManager(true);

            if (view != null)
            {
                this.view = view;
                this.view.startServerHandler += new newStartServerHandler(startServer);
                this.view.stopServerHandler  += new newStopServerHandler(stopServer);
                this.view.showView();
            }
            else
            {
                ps.start(port, false);
            }
        }
Exemplo n.º 8
0
 public ServerControl(IServerModel serverModel, IServerView serverView)
 {
     this._serverModel = serverModel;
     this._serverView = serverView;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Initialize variables. If a view isn't provided, it starts the process in background.
 /// </summary>
 /// <param name="view"></param>
 public ServerController(IServerView view) : this(null, view)
 {
 }
Exemplo n.º 10
0
        public void CloseServerTabView(IServerView p_ServerView)
        {
            int l_Index = m_SoftwareView.CloseServerTabView(p_ServerView);

            m_ServerControllerList.RemoveAt(l_Index - 1);
        }
Exemplo n.º 11
0
 private static void Present( IServerModel aModel, IServerView aView )
 {
     aModel.EventOccurred += aView.LogEvent;
     aView.AbortRequested += aModel.Abort;
     return;
 }
Exemplo n.º 12
0
 public ServerPresenter(IServerView view)
 {
     this.view = view;
 }
Exemplo n.º 13
0
 public ServerPresenter(IServerView view, IServerModel model)
 {
     _view = view;
     _model = model;
 }
Exemplo n.º 14
0
 public void AddObserver(IServerView clientView)
 {
     _observers.Add(clientView);
 }
Exemplo n.º 15
0
        public ChatServer(IServerView view, IEnumerable <ILogging> loggers)
        {
            this.serverView = view;

            this.loggers = loggers;
        }
Exemplo n.º 16
0
 public void RemoveObserver(IServerView serverView)
 {
     if (ServerStaticMembers.Observers != null)
     {
         if (ServerStaticMembers.Observers.Contains(serverView))
         {
             ServerStaticMembers.Observers.Remove(serverView);
         }
     }
 }
Exemplo n.º 17
0
 public void AddView(IServerView view)
 {
     views.Add(view);
 }
Exemplo n.º 18
0
 public void SetView(IServerView serverView)
 {
     this._serverView = serverView;
 }
Exemplo n.º 19
0
 public ServerController(IServerView view)
 {
     _view = view;
     view.SetController(this);
 }
Exemplo n.º 20
0
 public void RemoveObserver(IServerView clientView)
 {
     _observers.Remove(clientView);
 }