Exemple #1
0
        private void AgentWindow_Load(object sender, EventArgs e)
        {
            this.CancelQuit = true;
            InitSysNotifyIcon();
            // StatusBar labels
            this.statusStrip.Items.Add(this.statusLabel);
            this.statusStrip.Items.Add(new ToolStripSeparator());
            this.statusStrip.Items.Add(this.addressLabel);
            this.statusStrip.Items.Add(new ToolStripSeparator());
            this.statusStrip.Items.Add(this.counterLabel);
            this.statusStrip.Items.Add(new ToolStripSeparator());
            this.statusStrip.Items.Add(this.uploadLabel);
            this.statusStrip.Items.Add(new ToolStripSeparator());
            this.statusStrip.Items.Add(this.pingLabel);

            this.CheckLastSendTime = true;

            this.cmdReceiver = new CommandReceiver(Ports.DataClient);
            cmdReceiver.Start(this.OnLocalCommand);

            this.InitDetailsListView();
            this.Start();
        }
Exemple #2
0
 private void OpenLocalCommandReceiver()
 {
     try
     {
         this.cmdReceiver = new CommandReceiver(Ports.Main);
         SynchronizationContext sc = SynchronizationContext.Current;
         this.cmdReceiver.Start(this.OnReceivedCommandLine);
     }
     catch(Exception e)
     {
         MessageBox.Show("Command receiver initialized failed.");
     }
 }
Exemple #3
0
        private void AgentWindowLoad(object sender, EventArgs e)
        {
            LoggerClient.Initialize();
            this.logger.Send("ScadaDataClient", "Data (upload) Program starts at " + DateTime.Now);

            this.InitSysNotifyIcon();
            this.MakeWindowShownFront();
            this.ShowInTaskbar = false;
            this.SetExceptionToolStripMenuItem.Checked = false;
            this.statusStrip.Items.Add(this.GetConnetionString());
            this.statusStrip.Items.Add(new ToolStripSeparator());
            this.statusStrip.Items.Add("MS: " + Settings.Instance.Mn);
            this.statusStrip.Items.Add(new ToolStripSeparator());
            // this.statusStrip.Items.Add("数据中心IP:");

            this.cmdReceiver = new CommandReceiver(Ports.DataClient);
            cmdReceiver.Start(this.OnLocalCommand);

            SystemEvents.SessionEnding += SystemEvents_SessionEnding;

            this.InitDetailsListView();
            if (this.StartState)
            {
                this.Start();
            }
        }
Exemple #4
0
		private void WindowLoaded(object sender, RoutedEventArgs e)
        {
            MainWindow.statusBar = this.StatusBar;
            this.Title = Settings.Instance.ApplicationName;


			// TODO: Window Loaded.
			this.LoadConfig();
			this.LoadDataProvider();

            // Device List
            this.DeviceList.ClickDeviceItem += this.OnDeviceItemClicked;
            this.DeviceList.MainWindow = this;

			Config cfg = Config.Instance();
			string[] deviceKeys = cfg.DeviceKeys;
			foreach (string deviceKey in deviceKeys)
            {
				string displayName = cfg.GetDisplayName(deviceKey);
				if (!string.IsNullOrEmpty(displayName))
				{
					this.DeviceList.AddDevice(displayName, deviceKey);
				}
            }

            this.AutoStationLabel.Text = Settings.Instance.StationName;
            this.CommStatusLabel.Text = "通信状态";
            this.DataCounterLabel.Text = "数据统计";

            this.AddPageEntry("自动站介绍", PanelManager.StationIntroduction, this.FirstShowTree);
            this.AddPageEntry("设备运行状态", PanelManager.DevicesRunStatus, this.FirstShowTree);
            if (Settings.Instance.IsCAS)
            {
                this.AddPageEntry("特征核素识别系统", PanelManager.CinderellaRunStatus, this.FirstShowTree);
            }
            this.AddPageEntry("当前通信状态", PanelManager.CurrentCommStatus, this.CommStatusTree);
            // this.AddPageEntry("历史通信状态", PanelManager.HistoryCommStatus, this.CommStatusTree);

            this.AddPageEntry("数据统计", PanelManager.DataCounter, this.CounterTree);
            // this.AddPageEntry("数据分析", this.CounterTree);


            this.ShowDataViewPanel("scada.hpic");
            // this.OnDeviceItemClicked(null, null);
            this.loaded = true;
            // Max when startup;
            this.OnMaxButton(null, null);

            this.SynchronizationContext = SynchronizationContext.Current;
            try
            {
                this.commandReceiver = new CommandReceiver(Ports.MainVision);
                this.commandReceiver.Start(this.OnReceivedCommandLine);
            }
            catch (Exception)
            {
                System.Windows.Forms.MessageBox.Show("Command receiver initialized failed.");
            }

            // watch changed file
            var path = LogPath.GetDeviceLogFilePath("scada.hpge");
            if (!File.Exists(path))
            {
                return;
            }
            this.hpgeFileWatcher = new FileSystemWatcher(path);
            this.hpgeFileWatcher.IncludeSubdirectories = true;
            this.hpgeFileWatcher.Created += (object s, FileSystemEventArgs evt) =>
            {
                string fileName = evt.Name.ToLower();
                string filePath = System.IO.Path.Combine(path, fileName);
                this.SynchronizationContext.Post(new SendOrPostCallback((o) =>
                {
                    this.panelManager.SendFileCreatedToCinderellaPage(filePath);
                }), null);
            };
            this.hpgeFileWatcher.EnableRaisingEvents = true;
        }