コード例 #1
0
 public override bool OnInit()
 {
     try
     {
         if (_clientBuilder.BuildTaskName())
         {
             if (_clientBuilder.BuildLog())
             {
                 _log.NormalLog(string.Format("{0}:Init=>Initing ", "OnInit()"));
                 if (_clientBuilder.BuildConfig())
                 {
                     if (_clientBuilder.BuildPoints())
                     {
                         if (_clientBuilder.BuildClient())
                         {
                             _timeRead = new Timer.Timer(_config.PollingTime);
                             _log.NormalLog(string.Format("{0}:Initing=>Inited ", "OnInit()"));
                             return(true);
                         }
                     }
                 }
             }
         }
         return(false);
     }
     catch (Exception e)
     {
         _log.ErrorLog(string.Format("Init fail:{0}", e.Message));
         return(false);
     }
 }
コード例 #2
0
        public bool OnInit()
        {
            _log.NormalLog(string.Format("ModbusTCPClientHanderTask:Init=>Initing "));
            try
            {
                //获取配置
                _config = ReaderXMLUtil.ReadXMLConfig <ModbusTCPClientConfig>("../../../../conf/Configuration.xml", ModbusTCPClientConfig.ReadConfig, "setup", "ModbusTCPClientHandlerTask")[0];
                if (_config.IpAddress == "" || _config.SignalListFilePath == "")
                {
                    _log.ErrorLog(string.Format("ModbusTCPClientHanderTask Init fail:{0}", "IP address or Signal file path is null!"));
                    return(false);
                }
                _setup   = new EthernetSetUp(_config.IpAddress, _config.Port);
                _timeout = new TimeOut("ModbusTCPClientHanderTask", _config.TimeOut, _log);

                _timeRead = new Timer.Timer(_config.PollingTime);

                _client = new ModbusTCPClient(_setup, _timeout, _log);

                //获取点数据
                _workbook = XmlSerialiaztion.XmlDeserial <XMLWorkbook>(_config.SignalListFilePath, _log);
                _points   = PointsCollcetCreate.Create(_workbook, _log);
                //点数据注册
                PointsRegister.Register(ref _points, _log);
                _log.NormalLog(string.Format("ModbusTCPClientHanderTask:Initing=>Inited "));
                return(true);
            }
            catch (Exception e)
            {
                _log.ErrorLog(string.Format("ModbusTCPClientHanderTask Init fail:{0}", e.Message));
                return(false);
            }
        }
コード例 #3
0
        /// <summary>
        /// Inicializa todas las variables y objetos privados del servicio.
        /// </summary>
        private void Initialize()
        {
            try
            {
                /// Controla que está configurado el intervalo de  ejecución
                /// del servicio.
                _Interval = Fwk.Blocking.BlockingService.Properties.Settings.Default.Interval;// ConfigurationManager.GetProperty("BlockingModel", "Interval");


                _WaitForComplete = Fwk.Blocking.BlockingService.Properties.Settings.Default.WaitForComplete;


                /// Inicializa el Timer
                _Timer = new Timer.Timer();

                /// Agrega el event handler para los intervalos del Timer.
                _Timer.Elapsed += new Timer.ElapsedEventHandler(_Timer_Elapsed);

                /// Setea el intervalo de  ejecución del Timer a partir
                /// del archivo de configuración.
                _Timer.Interval = _Interval * 1000;
            }
            catch (Exception ex)
            {
                BlockingHelper.WriteLog(
                    String.Concat("Se produjo una excepción al inicializar el servicio.\r\n\r\n", Fwk.Exceptions.ExceptionHelper.GetAllMessageException(ex)),
                    EventLogEntryType.Error);

                throw ex;
            }
        }
コード例 #4
0
        /// <summary>
        /// コンストラクタです。
        /// </summary>
        /// <param name="owner">タイムラインが描画されている親フォーム。</param>
        /// <param name="timeline">このインスタンスに紐付けるタイムライン。</param>
        public TimeLineFrame(MainForm owner, ITimeLine timeline)
        {
            InitializeComponent();
            this.owner        = owner;
            panel.MouseWheel += Panel_MouseWheel;

            // タイムラインにこの枠を紐付ける
            this.timeline          = timeline;
            timeline.Panel         = panel;
            labelTimeLineName.Text = timeline.TimeLineName;

            // ストリーミングイベントの設定、ストリーミングの開始
            if (timeline is TimeLineMastodon)
            {
                var tl = timeline as TimeLineMastodon;
                tl.SetOnUpdate((_, e) =>
                {
                    tl.AddStatus(new TwitdonMastodonStatus(e.Status));
                });
            }
            else if (timeline is TimeLineTwitter)
            {
                var tl = timeline as TimeLineTwitter;
                tl.OnGetStatusMessage.Subscribe(x => tl.AddStatus(new TwitdonTwitterStatus(x.Status)));
            }

            // タイマーイベントの追加
            var timer = new Timer.Timer();

            timer.Elapsed  += new Timer.ElapsedEventHandler(Timer_Update);
            timer.Interval  = 1000;
            timer.AutoReset = true;
            timer.Enabled   = true;
        }
コード例 #5
0
 public LogglyAppender()
 {
     LogglyAsync = new LogglyAsyncHandler();
     Timer.Timer t = new Timer.Timer();
     t.Interval = 20000;
     t.Enabled  = true;
     t.Elapsed += t_Elapsed;
 }
コード例 #6
0
 public LogglyAppender()
 {
     LogglyAsync = new LogglyAsyncHandler();
     Timer.Timer t = new Timer.Timer();
     t.Interval = 20000;
     t.Enabled = true;
     t.Elapsed += t_Elapsed;
 }
コード例 #7
0
        /*
         * private void MainWindow_OnClosing(object sender, CancelEventArgs e) {
         *      AllowWindowClose = true;
         *
         *      if(!AllowWindowClose) {
         *              if(_exitDialog()) {
         *                      AllowWindowClose = true;
         *              } else {
         *                      e.Cancel = true;
         *              }
         *      }
         * }
         */
        #endregion

        #region [AUTOCLOSE]

        private void autoclose()
        {
            if (_viewModel.SetTimeSuccess != null && _viewModel.SetTimeSuccess.Value)
            {
                MainUI.Title = $"Setting Success! Closing in {_viewModel.CloseSuccessWindowAfterMiliseconds/1000} sec";
                //AllowWindowClose = true;

                _closingTimer = new Timer.Timer()
                {
                    Interval = _viewModel.CloseSuccessWindowAfterMiliseconds
                };
                _closingTimer.Elapsed += (o, args) => {
                    Dispatcher.Invoke(Close);
                };
                _closingTimer.Start();
            }
            else
            {
                MainUI.Title = "Setting time error!";
            }
        }
コード例 #8
0
ファイル: BlockingService.cs プロジェクト: gpanayir/sffwk
        /// <summary>
        /// Inicializa todas las variables y objetos privados del servicio.
        /// </summary>
        private void Initialize()
        {
            try
            {
                /// Controla que está configurado el intervalo de  ejecución
                /// del servicio.
                _Interval = Fwk.Blocking.BlockingService.Properties.Settings.Default.Interval;// ConfigurationManager.GetProperty("BlockingModel", "Interval");


                _WaitForComplete = Fwk.Blocking.BlockingService.Properties.Settings.Default.WaitForComplete;


                /// Inicializa el Timer
                _Timer = new Timer.Timer();

                /// Agrega el event handler para los intervalos del Timer.
                _Timer.Elapsed += new Timer.ElapsedEventHandler(_Timer_Elapsed);

                /// Setea el intervalo de  ejecución del Timer a partir
                /// del archivo de configuración.
                _Timer.Interval = _Interval * 1000;
            }
            catch (Exception ex)
            {
                BlockingHelper.WriteLog(
                    String.Concat("Se produjo una excepción al inicializar el servicio.\r\n\r\n" , Fwk.Exceptions.ExceptionHelper.GetAllMessageException(ex)),
                    EventLogEntryType.Error);

                throw ex;
            }
        }
コード例 #9
0
        private async void SendData()
        {
            
            await Task.Delay(_data.PreDelay);
            Timer.Timer _timeout = new Timer.Timer() { AutoReset = false, Interval = _data.SendTimeOut };
            _timeout.Elapsed += _timeout_Elapsed;
            _data.ClearBuffer();

            _timeout.Start();
            if (!_interface.Mode)
            {
                Debug.WriteLine("Interface not connected");
                Stop(this, EventArgs.Empty);
                return;
            }
            _interface.SendBytes(_data.CommandValue.ToArray());
            Debug.WriteLine("DataSender: data send: " + _data.ModuleName);
        }