123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Threading;
- using log4net;
- using WisdomClient.data;
- using WisdomClient;
- namespace IntelligentControlForsx.MyControls.syz
- {
- public partial class ZTControl : UserControl
- {
- private ILog logger = LogManager.GetLogger("AppInfoLog");
- private Dictionary<string, IPointData> dictPoint;
- public ZTControl()
- {
- InitializeComponent();
- }
- private void ZTControl_Load(object sender, EventArgs e)
- {
- dictPoint = new Dictionary<string, IPointData>();
- foreach (var p in this.pnlImage.Controls)
- {
- IPointData pd = p as IPointData;
- if (pd != null && String.IsNullOrWhiteSpace(pd.TagId) == false)
- {
- dictPoint.Add(pd.TagId, pd);
- }
- }
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- if (isLoadding == true)
- return;
- Thread ayscThread = new Thread(LoadData);
- ayscThread.IsBackground = true;
- ayscThread.Start();
- }
- public void DeActive()
- {
- timer1.Stop();
- this.Hide();
- }
- public void Active()
- {
- this.Show();
- Thread ayscThread = new Thread(LoadData);
- ayscThread.IsBackground = true;
- ayscThread.Start();
- timer1.Start();
- }
- private bool isLoadding = false;
- private void LoadData()
- {
- if (isLoadding == true)
- return;
- isLoadding = true;
- try
- {
- UpdatePnlImage();
- }
- catch (Exception ex)
- {
- logger.Info("读取实时数据失败!ex=" + ex.Message);
- }
- finally
- {
- isLoadding = false;
- }
- }
- private void UpdatePnlImage()
- {
- if (dictPoint == null || dictPoint.Count < 1)
- return;
- var points = dictPoint.Keys.ToArray();
- Dictionary<string, TsData> dictResult = RestfulClient.findLatestByTagNames(points);
- lock (this.pnlImage)
- {
- this.BeginInvoke(
- (Action)delegate
- {
- for (int i = 0; i < points.Length; i++)
- {
- String tagId = points[i];
- if (tagId == "NSSDQ.NX_GD_NSSF_DQ_P1_L1_001_DI0088")
- {
- TsData tt = dictResult[tagId];
- Console.WriteLine("123");
- }
-
- if (dictResult.ContainsKey(tagId) && dictPoint.ContainsKey(tagId))
- {
- TsData tsData = dictResult[tagId];
- IPointData pd = dictPoint[tagId];
- pd.TagData = tsData;
- }
- }
- });
- }
- }
- }
- }
|