private void frmMain_Load(object sender, EventArgs e) { ConnectMES(); m_AliveMoniter = new AliveNotifier(L3Session); m_AliveMoniter.L3Session = L3Session; m_AliveMoniter.Start(); m_Cfg = new NCDataConfig("NCData.config"); string strDataDir = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "DataSent"); string strDataFail = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "DataFailed"); Directory.CreateDirectory(strDataDir); Directory.CreateDirectory(strDataFail); ConnectMES(); txtMESServer.Text = L3Session.ConnectionStr; txtNCServer.Text = Properties.Settings.Default.NCServer; pbNCStatus.Image = MainResources.button_blue.ToBitmap(); NCDataItemConfig[] datas = m_Cfg.GetDatas(); foreach (NCDataItemConfig data in datas) { string subtgt = data.Subscribe; string[] items = subtgt.Split('.'); L3Session.Subscribe(items[0], items[1], AppSvrIF.SubscribeType.Change); lstTypes.Items.Add(data); } }
public void ThreadFunc(object param) { AliveNotifier notifier = param as AliveNotifier; if (notifier == null) { return; } if (notifier.L3Session == null) { return; } while (!notifier.ShouldQuit) { object obj = null; int i = 0; notifier.L3Session.Get(@"XGMESLogic\BaseDataMag\CCommunicationStatus\NC", "WatchDog", ref obj); if (obj != null) { i = Convert.ToInt32(obj); i = i % 9999 + 1; } if (i != 0) { notifier.L3Session.Set(@"XGMESLogic\BaseDataMag\CCommunicationStatus\NC", "WatchDog", i); } Thread.Sleep(5000); } }