Main.cs 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870
  1. using System;
  2. using System.Data;
  3. using System.Text;
  4. using System.Collections.Generic;
  5. using System.Drawing;
  6. using System.Threading;
  7. using System.Windows.Forms;
  8. using DevExpress.XtraBars;
  9. using DevExpress.XtraGrid.Views.Grid;
  10. using DevExpress.XtraBars.Ribbon;
  11. using DevExpress.XtraEditors.Controls;
  12. using DevExpress.XtraEditors;
  13. using UAS_PLCDataReader.DataOperate;
  14. using UAS_PLCDataReader.Entity;
  15. using UAS_PLCDataReader.PublicMethod;
  16. using UAS_PLCDataReader.CustomerControl.PictureEditWithText;
  17. using UAS_PLCDataReader.Device.Infomation;
  18. namespace UAS_PLCDataReader
  19. {
  20. public partial class Main : RibbonForm
  21. {
  22. StringBuilder sql = new StringBuilder();
  23. //用于设备状态查询界面SQL查看
  24. StringBuilder DeviceStatusQuerySQL = new StringBuilder();
  25. //用于设备主档资料查询界面SQL查看
  26. StringBuilder DeviceListQuerySQL = new StringBuilder();
  27. DataHelper dh = SystemInf.dh;
  28. ModeBusTCPServer mbt = new ModeBusTCPServer();
  29. List<string> SQL = new List<string>();
  30. //存放所有的设备返回的数据,用于比较
  31. public static Dictionary<string, Entity.Device> ReturnData = new Dictionary<string, Entity.Device>();
  32. /// <summary>
  33. /// 需要更新的设备列表
  34. /// </summary>
  35. public static Queue<Entity.Device> QueueUpdateDevice = new Queue<Entity.Device>();
  36. #region 初始化代码
  37. public Main()
  38. {
  39. InitializeComponent();
  40. CheckForIllegalCrossThreadCalls = false;
  41. dpc_enableCheckEdit.QueryCheckStateByValue += CheckedEdit_QueryCheckStateByValue;
  42. CommandSetRepositoryItemComboBox1.ParseEditValue += CommandSetRepositoryItemComboBox1_ParseEditValue;
  43. CheckEditCommandSet.QueryCheckStateByValue += CheckedEdit_QueryCheckStateByValue;
  44. PollSettingItemSearchLookUpEdit.ParseEditValue += PollSettingItemSearchLookUpEdit_ParseEditValue;
  45. GridViewPollSetting.RowCellStyle += GridViewPollSetting_RowCellStyle;
  46. #region 添加发送接收编码规则的静态值
  47. ComboBoxData cbd = new ComboBoxData();
  48. cbd.Text = "UTF-8";
  49. cbd.Value = "UTF-8";
  50. ComboBoxData cbd1 = new ComboBoxData();
  51. cbd1.Text = "Hexadecimal";
  52. cbd1.Value = "Hexadecimal";
  53. ComboBoxData cbd2 = new ComboBoxData();
  54. cbd2.Text = "ASCII";
  55. cbd2.Value = "ASCII";
  56. CommandSetRepositoryItemComboBox1.Items.Add(cbd);
  57. CommandSetRepositoryItemComboBox1.Items.Add(cbd1);
  58. CommandSetRepositoryItemComboBox1.Items.Add(cbd2);
  59. #endregion
  60. }
  61. private void CommandSetRepositoryItemComboBox1_ParseEditValue(object sender, ConvertEditValueEventArgs e)
  62. {
  63. string val = "";
  64. if (e.Value != null)
  65. {
  66. val = e.Value.ToString();
  67. }
  68. else
  69. {
  70. val = "FALSE";//默认为不选
  71. }
  72. e.Value = val;
  73. e.Handled = true;
  74. }
  75. private void PollSettingItemSearchLookUpEdit_ParseEditValue(object sender, ConvertEditValueEventArgs e)
  76. {
  77. e.Handled = true;
  78. }
  79. private void Main_Load(object sender, EventArgs e)
  80. {
  81. //设备列表
  82. GridDeviceList.GetDataSQL = "SELECT 0 CHECKEDCOLUMN,DE_ID,DE_CODE,DE_NAME,DE_SPEC,DE_INDATE,DE_RUNSTATUS,DE_ADDRESS,DE_INMAN,DE_LINECODE,DE_WCCODE,DE_VENDCODE,DE_VENDNAME,DE_STEPCODE,DE_STEPNAME,DE_SOURCECODE FROM DEVICE ORDER BY DE_CODE".ToUpper();
  83. GridDeviceList.TableName = "device";
  84. GridDeviceList.ID = "de_id";
  85. GridDeviceList.InsertSQL = "INSERT INTO DEVICE(DE_ID,DE_CODE,DE_NAME,DE_SPEC,DE_INDATE,DE_RUNSTATUS,DE_ADDRESS,DE_INMAN,DE_LINECODE,DE_WCCODE,DE_VENDCODE,DE_VENDNAME,DE_STEPCODE,DE_STEPNAME,DE_SOURCECODE) VALUES(DEVICE_SEQ.NEXTVAL,:DE_CODE,:DE_NAME,:DE_SPEC,sysdate,:DE_RUNSTATUS,:DE_ADDRESS,:DE_INMAN,:DE_LINECODE,:DE_WCCODE,:DE_VENDCODE,:DE_VENDNAME,:DE_STEPCODE,:DE_STEPNAME,:DE_SOURCECODE)";
  86. ButtonAddDevice.Grid = GridDeviceList;
  87. ButtonSaveDevice.Grid = GridDeviceList;
  88. ButtonDeleteDevice.Grid = GridDeviceList;
  89. //ToolPageControlDeviceList.Gridcontrol = GridDeviceList;
  90. //轮询业务
  91. //GridPolling.GetDataSQL = "select 0 CHECKEDCOLUMN,pl_id,pl_code,pl_name,pl_type,pl_dccode,pl_remark from polling".ToUpper();
  92. //GridPolling.ID = "pl_id";
  93. //GridPolling.TableName = "polling";
  94. //GridPolling.InsertSQL = "insert into polling(pl_id,pl_code,pl_name,pl_type,pl_dccode,pl_remark) values(polling_seq.nextval,:pl_code,:pl_name,:pl_type,:pl_dccode,:pl_remark)";
  95. //ButtonDeletePolling.Grid = GridPolling;
  96. //ButtonSavePolling.Grid = GridPolling;
  97. //ButtonAddPolling.Grid = GridPolling;
  98. //轮询配置界面
  99. GridPollingSetting.GetDataSQL = "SELECT '' POLLSETTINGSTATUSCOLUMN,0 CHECKEDCOLUMN,DPC_MAN,DPC_ID,DPC_DECODE,DPC_DENAME ,DPC_INTERVAL ,DPC_DCCODE ,DPC_FUNCTION , nvl(DPC_ENABLE,0)DPC_ENABLE,DPC_STATUS,DPC_REMARK,EM_NAME FROM DEVICEPOLLINGCONFIG left join EMPLOYEE on em_code=dpc_man WHERE DPC_MAN='" + User.UserCode + "' ORDER BY DPC_ID";
  100. GridPollingSetting.ID = "DPC_ID";
  101. GridPollingSetting.TableName = "DEVICEPOLLINGCONFIG";
  102. GridPollingSetting.InsertSQL = "insert into DEVICEPOLLINGCONFIG(DPC_ID,DPC_DECODE,DPC_DENAME ,DPC_INTERVAL ,DPC_DCCODE ,DPC_FUNCTION , DPC_ENABLE,DPC_STATUS ,DPC_REMARK,DPC_MAN) values(DEVICEPOLLINGCONFIG_seq.nextval,:DPC_DECODE ,:DPC_INTERVAL ,:DPC_DCCODE ,:DPC_FUNCTION , :DPC_ENABLE,:DPC_STATUS ,:DPC_REMARK,'" + User.UserCode + "')";
  103. ButtonSaveCommandSet.Grid = GridPollingSetting;
  104. ButtonNewCommandSet.Grid = GridPollingSetting;
  105. ButtonDeleteCommandSet.Grid = GridPollingSetting;
  106. //指令设置界面
  107. GridCommandSetting.GetDataSQL = "select 0 CHECKEDCOLUMN,dc_id,dc_code,dc_name,dc_type,dc_value,dc_sendcoding,dc_receivecoding,db_name,dc_man,dc_date from devicecommand left join devicebrand on db_code=dc_debrand".ToUpper();
  108. GridCommandSetting.TableName = "devicecommand";
  109. GridCommandSetting.ID = "dc_id";
  110. GridCommandSetting.InsertSQL = "insert into devicecommand(dc_id,dc_code,dc_name,dc_value,dc_debrand,dc_sendcoding,dc_receivecoding,dc_man,dc_date) values(devicecommand_seq.nextval,:dc_code,:dc_name,:dc_value,'" + BaseUtil.GetComboxEditValue(Brand) + "',:dc_sendcoding,:dc_receivecoding,'" + User.UserName + "',sysdate)";
  111. ButtonSaveCommand.Grid = GridCommandSetting;
  112. ButtonDeleteCommand.Grid = GridCommandSetting;
  113. ButtonNewCommand.Grid = GridCommandSetting;
  114. //设备联网配置界面
  115. GridDeviceNetSetting.GetDataSQL = "SELECT 0 CHECKEDCOLUMN,DNC_ID,DNC_DECODE,DNC_GATEWAY,DNC_UPPERIP,DNC_PORT,DNC_MAC,DNC_IP,DNC_TYPE FROM DEVICENETCONFIG order by DNC_ID";
  116. GridDeviceNetSetting.ID = "dnc_id";
  117. GridDeviceNetSetting.TableName = "DEVICENETCONFIG";
  118. GridDeviceNetSetting.InsertSQL = "insert into DEVICENETCONFIG(DNC_ID,DNC_DECODE,DNC_GATEWAY,DNC_UPPERIP,DNC_PORT,DNC_MAC,DNC_IP,DNC_TYPE) values(DEVICENETCONFIG_SEQ.NEXTVAL,:DNC_DECODE,:DNC_GATEWAY,:DNC_UPPERIP,:DNC_PORT,:DNC_MAC,:DNC_IP,:DNC_TYPE)";
  119. ButtonDeleteNetConfig.Grid = GridDeviceNetSetting;
  120. ButtonAddNetConfig.Grid = GridDeviceNetSetting;
  121. ButtonSaveNetConfig.Grid = GridDeviceNetSetting;
  122. TimerUpdateDevice.Start();
  123. Ptime = new Dictionary<int, PollingTimer>();
  124. }
  125. /// <summary>
  126. /// 关闭前将所有设备离线,状态更新为离线
  127. /// </summary>
  128. /// <param name="sender"></param>
  129. /// <param name="e"></param>
  130. private void Main_FormClosing(object sender, FormClosingEventArgs e)
  131. {
  132. dh.ExecuteSql("update devicepollingconfig set dpc_status='Stop' where dpc_status='Running'", "update");
  133. dh.ExecuteSql("update devicepollinglog set dpg_status='Stop' where dpg_status='Running'", "update");
  134. }
  135. #endregion
  136. #region 设备列表界面
  137. private void GridViewDeviceList_RowCellClick(object sender, RowCellClickEventArgs e)
  138. {
  139. string de_code = GridViewDeviceList.GetRowCellValue(e.RowHandle, "DE_CODE").ToString();
  140. DeviceDetailInfo ddi = new DeviceDetailInfo(de_code);
  141. ddi.StartPosition = FormStartPosition.CenterScreen;
  142. ddi.ShowDialog();
  143. }
  144. private void PageDeviceList_VisibleChanged(object sender, EventArgs e)
  145. {
  146. if (PageDeviceList.PageVisible)
  147. {
  148. DataTable dt;
  149. //填充人员资料,工作中心,线别下拉框
  150. ComBoxDeviceListMan.Properties.DataSource = (DataTable)dh.ExecuteSql("select em_code,em_name from employee ", "select");
  151. dt = (DataTable)dh.ExecuteSql("select wc_code,wc_name from workcenter", "select");
  152. BaseUtil.FillComBoxEditWidthDataTable(ComboxDeviceListWC, "wc_name", "wc_code", dt, true);
  153. }
  154. }
  155. private void ButtonSaveDevice_Click(object sender, EventArgs e)
  156. {
  157. ButtonSaveDevice.DoSaveAfterHandler();
  158. sql.Clear();
  159. sql.Append("update device set de_inman='" + User.UserName + "' where de_id=:de_id");
  160. if (ButtonSaveDevice.LastSaveID != null && ButtonSaveDevice.LastSaveID.Length > 0)
  161. {
  162. dh.BatchInsert(sql.ToString(), new string[] { "de_id" }, ButtonSaveDevice.LastSaveID);
  163. }
  164. GridDeviceList.RefreshData();
  165. }
  166. private void ComboxDeviceListWC_SelectedIndexChanged(object sender, EventArgs e)
  167. {
  168. DeviceListQuerySQL.Clear();
  169. string WC = BaseUtil.GetComboxEditValue(ComboxDeviceListWC);
  170. DeviceListQuerySQL.Append("select 0 CHECKEDCOLUMN,de_id,de_code,de_name,de_spec,de_indate,de_runstatus,de_address,de_wccode,de_inman,de_linecode");
  171. DeviceListQuerySQL.Append("de_vendcode,de_vendname,de_stepcode,de_stepname,DE_SOURCECODE from device where de_wccode='" + WC + "' order by de_code");
  172. sql.Clear();
  173. if (WC == "全部")
  174. sql.Append("select li_code,li_name from line");
  175. else
  176. sql.Append("select li_code,li_name from line where li_wccode='" + WC + "'");
  177. DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  178. BaseUtil.FillComBoxEditWidthDataTable(ComboxDeviceListLC, "li_code", "li_name", dt, true);
  179. RefreshDeviceData();
  180. }
  181. private void ComboxDeviceListLC_SelectedIndexChanged(object sender, EventArgs e)
  182. {
  183. DeviceListQuerySQL.Clear();
  184. string WC = BaseUtil.GetComboxEditValue(ComboxDeviceListWC);
  185. string LC = BaseUtil.GetComboxEditValue(ComboxDeviceListLC);
  186. DeviceListQuerySQL.Append("select 0 CHECKEDCOLUMN,de_id,de_code,de_name,de_spec,de_indate,de_runstatus,de_address,de_wccode, ");
  187. DeviceListQuerySQL.Append("de_vendcode,de_vendname,de_inman,de_linecode,de_stepcode,de_stepname,DE_SOURCECODE from device ");
  188. if (WC != "全部" && LC != "全部")
  189. DeviceListQuerySQL.Append(" where de_wccode='" + WC + "' and de_linecode='" + LC + "' ");
  190. if (WC == "全部" && LC != "全部")
  191. DeviceListQuerySQL.Append(" where de_linecode='" + LC + "' ");
  192. if (WC != "全部" && LC == "全部")
  193. DeviceListQuerySQL.Append(" where de_wccode='" + WC + "' ");
  194. DeviceListQuerySQL.Append("order by de_code");
  195. RefreshDeviceData();
  196. }
  197. private void ComBoxDeviceListMan_EditValueChanged(object sender, EventArgs e)
  198. {
  199. }
  200. private void RefreshDeviceData()
  201. {
  202. GridDeviceList.GetDataSQL = DeviceListQuerySQL.ToString();
  203. GridDeviceList.RefreshData();
  204. }
  205. #endregion
  206. #region 界面通用事件
  207. /// <summary>
  208. /// 选项卡切换不同XPage
  209. /// </summary>
  210. /// <param name="sender"></param>
  211. /// <param name="e"></param>
  212. private void ButtonItem_ItemClick(object sender, ItemClickEventArgs e)
  213. {
  214. HideXPage(e.Item.Tag.ToString());
  215. }
  216. /// <summary>
  217. /// 根据点击按钮的Tag显示对应的XPage
  218. /// </summary>
  219. /// <param name="PageName"></param>
  220. private void HideXPage(string PageName)
  221. {
  222. for (int i = 0; i < MainTabControl.TabPages.Count; i++)
  223. {
  224. if (MainTabControl.TabPages[i].Name == PageName)
  225. MainTabControl.TabPages[i].PageVisible = true;
  226. else
  227. MainTabControl.TabPages[i].PageVisible = false;
  228. }
  229. }
  230. /// <summary>
  231. /// 勾选Grid的CheckBox
  232. /// </summary>
  233. /// <param name="sender"></param>
  234. /// <param name="e"></param>
  235. private void CheckedEdit_QueryCheckStateByValue(object sender, DevExpress.XtraEditors.Controls.QueryCheckStateByValueEventArgs e)
  236. {
  237. string val = "";
  238. if (e.Value != null)
  239. {
  240. val = e.Value.ToString();
  241. }
  242. else
  243. {
  244. val = "FALSE";//默认为不选
  245. }
  246. switch (val.ToUpper())
  247. {
  248. case "TRUE":
  249. case "YES":
  250. case "1":
  251. e.CheckState = CheckState.Checked;
  252. break;
  253. case "FALSE":
  254. case "NO":
  255. case "0":
  256. e.CheckState = CheckState.Unchecked;
  257. break;
  258. default:
  259. e.CheckState = CheckState.Checked;
  260. break;
  261. }
  262. e.Handled = true;
  263. }
  264. /// <summary>
  265. /// 设备数据更新列表
  266. /// </summary>
  267. /// <param name="sender"></param>
  268. /// <param name="e"></param>
  269. private void TimerUpdateDevice_Tick(object sender, EventArgs e)
  270. {
  271. Console.WriteLine("Begin" + QueueUpdateDevice.Count);
  272. while (QueueUpdateDevice.Count > 0)
  273. {
  274. Entity.Device item = QueueUpdateDevice.Dequeue();
  275. SQL.Clear();
  276. //更新轮询状态
  277. sql.Clear();
  278. sql.Append("update DEVICEPOLLINGCONFIG set dpc_status='Running' where dpc_decode='" + item.Decode + "' and dpc_dccode='" + item.Dccode + "'");
  279. dh.ExecuteSql(sql.ToString(), "update");
  280. //更新轮询日志状态
  281. sql.Clear();
  282. sql.Append("update DEVICEPOLLINGLOG set dpg_status='Running',dpg_senddatasize=nvl(dpg_senddatasize,0)+" + item.SendDataSize);
  283. sql.Append(",dpg_receivedatasize=nvl(dpg_receivedatasize,0)+" + item.ReceiveDataSize + ",dpg_count=nvl(dpg_count,0)+1 ");
  284. sql.Append(" where dpg_id=(select max(dpg_id) from DEVICEPOLLINGLOG where dpg_decode='" + item.Decode + "')");
  285. dh.ExecuteSql(sql.ToString(), "update");
  286. }
  287. Console.WriteLine("End" + QueueUpdateDevice.Count);
  288. }
  289. #endregion
  290. #region PageCommandSet业务代码(指令设置)
  291. /// <summary>
  292. /// 判断指令编号不能重复
  293. /// </summary>
  294. /// <param name="sender"></param>
  295. /// <param name="e"></param>
  296. private void ButtonSaveCommand_Click(object sender, EventArgs e)
  297. {
  298. GridCommandSetting.InsertSQL = "insert into devicecommand(dc_id,dc_code,dc_name,dc_value,dc_debrand,dc_sendcoding,dc_receivecoding,dc_man,dc_date) values(devicecommand_seq.nextval,:dc_code,:dc_name,:dc_value,'" + BaseUtil.GetComboxEditValue(Brand) + "',:dc_sendcoding,:dc_receivecoding,'" + User.UserName + "',sysdate)";
  299. ButtonSaveCommand.DoSaveAfterHandler();
  300. sql.Clear();
  301. sql.Append("update devicecommand set dc_man='" + User.UserName + "',dc_date=sysdate where dc_id=:dc_id");
  302. if (ButtonSaveCommand.LastSaveID != null && ButtonSaveCommand.LastSaveID.Length > 0)
  303. {
  304. dh.BatchInsert(sql.ToString(), new string[] { "dc_id" }, ButtonSaveCommand.LastSaveID);
  305. }
  306. GridCommandSetting.RefreshData();
  307. }
  308. /// <summary>
  309. /// 加载ComBox品牌数据
  310. /// </summary>
  311. /// <param name="sender"></param>
  312. /// <param name="e"></param>
  313. private void PageCommandSet_VisibleChanged(object sender, EventArgs e)
  314. {
  315. if (PageCommandSet.PageVisible)
  316. {
  317. DataTable dt = (DataTable)SystemInf.dh.ExecuteSql("select * from devicebrand", "select");
  318. BaseUtil.FillComBoxEditWidthDataTable(Brand, "db_name", "db_code", dt);
  319. GridCommandSetting.Condition = " where dc_debrand='" + BaseUtil.GetComboxEditValue(Brand) + "' order by dc_id";
  320. }
  321. }
  322. private void Brand_SelectedIndexChanged(object sender, EventArgs e)
  323. {
  324. GridCommandSetting.Condition = " where dc_debrand='" + BaseUtil.GetComboxEditValue(Brand) + "' order by dc_id";
  325. GridCommandSetting.RefreshData();
  326. }
  327. #endregion
  328. #region PagePollingSetting业务代码(轮询配置)
  329. PollingTask pt = new PollingTask();
  330. /// <summary>
  331. /// 绘制轮询配置状态栏
  332. /// </summary>
  333. List<int> PollSettingPaintRowIndex = new List<int>();
  334. private void ButtonStartPolling_Click(object sender, EventArgs e)
  335. {
  336. GridView grid = GridViewPollSetting;
  337. for (int i = 0; i < GridPollingSetting.RowCount; i++)
  338. {
  339. Polling pl = new Polling();
  340. pl.Id = int.Parse(GridViewPollSetting.GetRowCellValue(i, "DPC_ID").ToString());
  341. pl.DeviceCode = GridViewPollSetting.GetRowCellValue(i, "DPC_DECODE").ToString();
  342. pl.DeviceName = GridViewPollSetting.GetRowCellValue(i, "DPC_DENAME").ToString();
  343. pl.CommandCode = GridViewPollSetting.GetRowCellValue(i, "DPC_DCCODE").ToString();
  344. pl.Interval = int.Parse(GridViewPollSetting.GetRowCellValue(i, "DPC_INTERVAL").ToString());
  345. pl.Enable = GridViewPollSetting.GetRowCellValue(i, "DPC_ENABLE").ToString() != "0";
  346. pl.Dh = new DataHelper();
  347. if (pl.Enable)
  348. {
  349. //插入轮询日志
  350. sql.Clear();
  351. sql.Append("insert into DEVICEPOLLINGLOG(dpg_id,dpg_decode,dpg_starttime,dpg_interval)values");
  352. sql.Append("(DEVICEPOLLINGLOG_seq.nextval,'" + pl.DeviceCode + "',sysdate,'" + pl.Interval + "')");
  353. dh.ExecuteSql(sql.ToString(), "insert");
  354. sql.Clear();
  355. sql.Append("MERGE INTO DeviceRunstatus alias1 USING (select '" + pl.DeviceCode + "' dr_decode from dual) alias2 ");
  356. sql.Append("ON (alias1.dr_decode=alias2.dr_decode) WHEN MATCHED THEN UPDATE SET dr_startdate =sysdate ");
  357. sql.Append("WHEN NOT MATCHED THEN INSERT (Dr_id,dr_decode,dr_dename,Dr_runstatus,dr_startdate) VALUES (DeviceRunstatus_seq.nextval,");
  358. sql.Append("'" + pl.DeviceCode + "','" + pl.DeviceName + "','running',sysdate)");
  359. dh.ExecuteSql(sql.ToString(), "update");
  360. pt.AddTask(RunTask, pl);
  361. //添加到状态为运行的行
  362. PollSettingPaintRowIndex.Add(i);
  363. GridPollingSetting.Focus();
  364. }
  365. }
  366. }
  367. /// <summary>
  368. /// 绘制轮询状态
  369. /// </summary>
  370. /// <param name="sender"></param>
  371. /// <param name="e"></param>
  372. private void GridViewPollSetting_RowCellStyle(object sender, RowCellStyleEventArgs e)
  373. {
  374. if (e.Column.Name.ToUpper() == "POLLSETTINGSTATUSCOLUMN" && PollSettingPaintRowIndex.Contains(e.RowHandle))
  375. {
  376. e.Appearance.BackColor = Color.Green;
  377. }
  378. }
  379. Dictionary<int, PollingTimer> Ptime;
  380. private void RunTask(object i)
  381. {
  382. PollingTimer timer = new PollingTimer();
  383. Polling pl = (Polling)i;
  384. timer.Polling = i;
  385. timer.Interval = pl.Interval * 1000;
  386. timer.Elapsed += Timer_Tick;
  387. timer.Start();
  388. try
  389. {
  390. if (!Ptime.ContainsKey(pl.Id))
  391. Ptime.Add(pl.Id, timer);
  392. }
  393. catch (Exception)
  394. {
  395. if (!Ptime.ContainsKey(pl.Id))
  396. Ptime.Add(pl.Id, timer);
  397. }
  398. }
  399. Dictionary<string, ModBusTCPClient> client = new Dictionary<string, ModBusTCPClient>();
  400. /// <summary>
  401. /// 轮询执行的业务
  402. /// </summary>
  403. /// <param name="sender"></param>
  404. /// <param name="e"></param>
  405. private void Timer_Tick(object sender, EventArgs e)
  406. {
  407. PollingTimer timer = (PollingTimer)sender;
  408. Polling pl = (Polling)timer.Polling;
  409. DataHelper dh = pl.Dh;
  410. string Decode = pl.DeviceCode;
  411. string Dccode = pl.CommandCode;
  412. string DpcID = pl.Id.ToString();
  413. DataTable dt = (DataTable)dh.ExecuteSql("select dnc_ip,dnc_port from DEVICENETCONFIG where dnc_decode='" + Decode + "'", "select");
  414. DataTable dt1 = (DataTable)dh.ExecuteSql("select dc_sendcoding,dc_value,dc_receivecoding from devicecommand where dc_code='" + Dccode + "'", "select");
  415. if (dt.Rows.Count > 0)
  416. {
  417. string IP = dt.Rows[0]["dnc_ip"].ToString() + ":" + dt.Rows[0]["dnc_port"].ToString();
  418. string SendCoding = "";
  419. string ReceiveCoding = "";
  420. string Command = "";
  421. int SendCommandByteSize = 0;
  422. if (dt1.Rows.Count > 0)
  423. {
  424. SendCoding = dt1.Rows[0]["dc_sendcoding"].ToString();
  425. ReceiveCoding = dt1.Rows[0]["dc_receivecoding"].ToString();
  426. Command = dt1.Rows[0]["dc_value"].ToString();
  427. SendCommandByteSize = Encoding.Default.GetBytes(Command.ToCharArray()).Length;
  428. }
  429. if (client.ContainsKey(DpcID))
  430. {
  431. client[DpcID].Send(Command);
  432. }
  433. else
  434. {
  435. ModBusTCPClient modclient = new ModBusTCPClient(dt.Rows[0]["dnc_ip"].ToString(), int.Parse(dt.Rows[0]["dnc_port"].ToString()));
  436. client.Add(DpcID, modclient);
  437. }
  438. //发送指令
  439. //mbt.Send(IP, SendCoding, ReceiveCoding, Command);
  440. //如果不包含该项数据则在键值对中添加
  441. if (!ReturnData.ContainsKey(Decode))
  442. {
  443. //添加本地数据内容
  444. Entity.Device device = new Entity.Device();
  445. device.Decode = pl.DeviceCode;
  446. device.Dename = pl.DeviceName;
  447. device.StartTime = DateTime.Now;
  448. device.RunStatus = "Running";
  449. device.SendDataSize += SendCommandByteSize;
  450. device.SendCount += 1;
  451. device.Dccode = pl.CommandCode;
  452. ReturnData.Add(Decode, device);
  453. }
  454. else
  455. {
  456. //每次更新轮询的数据
  457. ReturnData[Decode].SendDataSize += SendCommandByteSize;
  458. ReturnData[Decode].SendCount += 1;
  459. //检测键值对是否发生变化,发生变化时赋予新值
  460. }
  461. //成功返回了信息
  462. if (client[DpcID].Returnvalue.ContainsKey(IP))
  463. {
  464. int ReceiveCommandByteSize = Encoding.Default.GetBytes(client[DpcID].Returnvalue[IP].ToCharArray()).Length;
  465. //存放返回的所有数据
  466. Dictionary<string, string> ItemData = new Dictionary<string, string>();
  467. int[] Arr = BaseUtil.GetDecimalData(BaseUtil.ASCIIToString(client[DpcID].Returnvalue[IP]), 8);
  468. for (int i = 0; i < Arr.Length; i++)
  469. {
  470. ItemData.Add("Item" + i, Arr[i].ToString());
  471. }
  472. if (!ReturnData.ContainsKey(Decode))
  473. {
  474. //添加本地数据内容
  475. Entity.Device device = new Entity.Device();
  476. device.Decode = pl.DeviceCode;
  477. device.Dename = pl.DeviceName;
  478. device.StartTime = DateTime.Now;
  479. device.RunStatus = "Running";
  480. device.ReceiveDataSize += ReceiveCommandByteSize;
  481. device.Dccode = pl.CommandCode;
  482. device.ItemData = ItemData;
  483. ReturnData.Add(Decode, device);
  484. }
  485. else
  486. {
  487. if (ReturnData[Decode].ItemData == null)
  488. {
  489. ReturnData[Decode].ItemData = ItemData;
  490. }
  491. //每次更新轮询的数据
  492. ReturnData[Decode].ReceiveDataSize += ReceiveCommandByteSize;
  493. //检测键值对是否发生变化,发生变化时赋予新值
  494. if ((BaseUtil.CheckDicDiff(ReturnData[Decode].ItemData, ItemData)))
  495. {
  496. ReturnData[Decode].ItemData = ItemData;
  497. QueueUpdateDevice.Enqueue(ReturnData[Decode]);
  498. LogicHandler.DoDeviceDataDiffLog(pl.DeviceCode, pl.DeviceName, pl.CommandCode, User.UserName);
  499. }
  500. }
  501. client[DpcID].Returnvalue.Remove(IP);
  502. //SQL.Clear();
  503. ////更新轮询状态
  504. //sql.Clear();
  505. //sql.Append("update DEVICEPOLLINGCONFIG set dpc_status='Running' where dpc_decode='" + Decode + "' and dpc_dccode='" + Dccode + "'");
  506. //dh.ExecuteSql(sql.ToString(), "update");
  507. ////更新轮询日志状态
  508. //sql.Clear();
  509. //sql.Append("update DEVICEPOLLINGLOG set dpg_status='Running',dpg_senddatasize=nvl(dpg_senddatasize,0)+" + SendCommandByteSize);
  510. //sql.Append(",dpg_receivedatasize=nvl(dpg_receivedatasize,0)+" + ReceiveCommandByteSize + ",dpg_count=nvl(dpg_count,0)+1 ");
  511. //sql.Append(" where dpg_id=(select max(dpg_id) from DEVICEPOLLINGLOG where dpg_decode='" + Decode + "')");
  512. //dh.ExecuteSql(sql.ToString(), "update");
  513. }
  514. else
  515. {
  516. //SQL.Clear();
  517. ////更新轮询状态
  518. //sql.Clear();
  519. //sql.Append("update DEVICEPOLLINGCONFIG set dpc_status='Stop' where dpc_decode='" + Decode + "' and dpc_dccode='" + Dccode + "'");
  520. //dh.ExecuteSql(sql.ToString(), "update");
  521. ////更新轮询日志状态
  522. //sql.Clear();
  523. //sql.Append("update DEVICEPOLLINGLOG set dpg_status='Running',dpg_senddatasize=nvl(dpg_senddatasize,0)+");
  524. //sql.Append(SendCommandByteSize + ",dpg_count=nvl(dpg_count,0)+1 ");
  525. //sql.Append("where dpg_id=(select max(dpg_id) from DEVICEPOLLINGLOG where dpg_decode='" + Decode + "')");
  526. //dh.ExecuteSql(sql.ToString(), "update");
  527. }
  528. }
  529. }
  530. /// <summary>
  531. /// 停止全部轮询
  532. /// </summary>
  533. /// <param name="sender"></param>
  534. /// <param name="e"></param>
  535. private void ButtonPausePolling_Click(object sender, EventArgs e)
  536. {
  537. foreach (var item in Ptime)
  538. {
  539. item.Value.Stop();
  540. }
  541. PollSettingPaintRowIndex.Clear();
  542. GridPollingSetting.Focus();
  543. client.Clear();
  544. Ptime.Clear();
  545. }
  546. private void GridViewPollSetting_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
  547. {
  548. if (e.Column.Name.ToUpper() == "DPC_ENABLE")
  549. {
  550. GridViewPollSetting.SetRowCellValue(e.RowHandle, e.Column, e.Value);
  551. if (GridViewPollSetting.GetRowCellValue(e.RowHandle, "DPC_ENABLE").ToString() == "0")
  552. {
  553. int id = int.Parse(GridViewPollSetting.GetRowCellValue(e.RowHandle, "DPC_ID").ToString());
  554. if (Ptime.ContainsKey(id))
  555. {
  556. Ptime[id].Stop();
  557. Ptime.Remove(id);
  558. client.Remove(id.ToString());
  559. PollSettingPaintRowIndex.Remove(e.RowHandle);
  560. }
  561. }
  562. else
  563. {
  564. Polling pl = new Polling();
  565. pl.Id = int.Parse(GridViewPollSetting.GetRowCellValue(e.RowHandle, "DPC_ID").ToString());
  566. pl.DeviceCode = GridViewPollSetting.GetRowCellValue(e.RowHandle, "DPC_DECODE").ToString();
  567. pl.DeviceName = GridViewPollSetting.GetRowCellValue(e.RowHandle, "DPC_DENAME").ToString();
  568. pl.Interval = int.Parse(GridViewPollSetting.GetRowCellValue(e.RowHandle, "DPC_INTERVAL").ToString());
  569. pl.CommandCode = GridViewPollSetting.GetRowCellValue(e.RowHandle, "DPC_DCCODE").ToString();
  570. pl.Enable = GridViewPollSetting.GetRowCellValue(e.RowHandle, "DPC_ENABLE").ToString() != "0";
  571. pl.Dh = new DataHelper();
  572. if (pl.Enable)
  573. pt.AddTask(RunTask, pl);
  574. PollSettingPaintRowIndex.Add(e.RowHandle);
  575. }
  576. }
  577. }
  578. private void GridViewPollSetting_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
  579. {
  580. }
  581. private void ButtonSaveCommandSet_Click(object sender, EventArgs e)
  582. {
  583. ButtonSaveCommandSet.DoSaveAfterHandler();
  584. sql.Clear();
  585. sql.Append("update DEVICEPOLLINGCONFIG set dpc_man='" + User.UserCode + "' where dpc_id=:dpc_id");
  586. if (ButtonSaveCommandSet.LastSaveID != null && ButtonSaveCommandSet.LastSaveID.Length > 0)
  587. {
  588. dh.BatchInsert(sql.ToString(), new string[] { "dpc_id" }, ButtonSaveCommandSet.LastSaveID);
  589. }
  590. GridPollingSetting.RefreshData();
  591. }
  592. /// <summary>
  593. /// 设置GridView多选放大镜
  594. /// </summary>
  595. /// <param name="sender"></param>
  596. /// <param name="e"></param>
  597. private void PagePollingSetting_VisibleChanged(object sender, EventArgs e)
  598. {
  599. if (PagePollingSetting.PageVisible)
  600. {
  601. //如果未开启则进行开启
  602. if (!mbt.IsOpen)
  603. mbt.Open();
  604. DataTable dt = (DataTable)SystemInf.dh.ExecuteSql("SELECT DC_CODE,DC_NAME,DC_REMARK FROM DEVICECOMMAND", "select");
  605. PollSettingItemSearchLookUpEdit.DataSource = dt;
  606. PollSettingItemSearchLookUpEdit.DisplayMember = "DC_CODE";
  607. PollSettingItemSearchLookUpEdit.ValueMember = "DC_CODE";
  608. }
  609. }
  610. #endregion
  611. #region 设备查看界面
  612. private void PageDeviceStatus_VisibleChanged(object sender, EventArgs e)
  613. {
  614. if (PageDeviceStatus.PageVisible)
  615. {
  616. DeviceStatusQuerySQL.Clear();
  617. DeviceStatusQuerySQL.Append("select distinct de_code,de_name,dpc_status,dpc_id from device left join DEVICEPOLLINGCONFIG on dpc_decode=de_code order by de_code");
  618. PaintDeviceStatusControl(DeviceStatusQuerySQL.ToString());
  619. //填充筛选条件,车间和线体
  620. DataTable dt = (DataTable)dh.ExecuteSql("select wc_code,wc_name from workcenter", "select");
  621. BaseUtil.FillComBoxEditWidthDataTable(ComboxDeviceStatusWC, "wc_name", "wc_code", dt, true);
  622. }
  623. }
  624. private void CheckEditDeviceStatusEnable_CheckedChanged(object sender, EventArgs e)
  625. {
  626. DeviceStatusQuerySQL.Clear();
  627. if (CheckEditDeviceStatusEnable.Checked)
  628. {
  629. DeviceStatusQuerySQL.Append("select distinct de_code,de_name,dpc_status,dpc_id from device left join DEVICEPOLLINGCONFIG ");
  630. DeviceStatusQuerySQL.Append("on dpc_decode=de_code where nvl(dpc_enable,0)<>0 order by de_code");
  631. }
  632. else
  633. {
  634. DeviceStatusQuerySQL.Append("select distinct de_code,de_name,dpc_status,dpc_id from device left join DEVICEPOLLINGCONFIG ");
  635. DeviceStatusQuerySQL.Append("on dpc_decode=de_code order by de_code");
  636. }
  637. PaintDeviceStatusControl(DeviceStatusQuerySQL.ToString());
  638. }
  639. private void ComboxDeviceStatusWC_SelectedIndexChanged(object sender, EventArgs e)
  640. {
  641. DeviceStatusQuerySQL.Clear();
  642. string WC = BaseUtil.GetComboxEditValue(ComboxDeviceStatusWC);
  643. if (CheckEditDeviceStatusEnable.Checked)
  644. {
  645. DeviceStatusQuerySQL.Append("select distinct de_code,de_name,dpc_status,dpc_id from device left join DEVICEPOLLINGCONFIG ");
  646. DeviceStatusQuerySQL.Append("on dpc_decode=de_code where nvl(dpc_enable,0)<>0 and de_wccode='" + WC + "' order by de_code");
  647. }
  648. else
  649. {
  650. DeviceStatusQuerySQL.Append("select distinct de_code,de_name,dpc_status,dpc_id from device left join DEVICEPOLLINGCONFIG ");
  651. DeviceStatusQuerySQL.Append("on dpc_decode=de_code where de_wccode='" + WC + "' order by de_code");
  652. }
  653. PaintDeviceStatusControl(DeviceStatusQuerySQL.ToString());
  654. sql.Clear();
  655. if (WC == "全部")
  656. sql.Append("select li_code,li_name from line");
  657. else
  658. sql.Append("select li_code,li_name from line where li_wccode='" + WC + "'");
  659. DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  660. BaseUtil.FillComBoxEditWidthDataTable(ComboxDeviceStatusLC, "li_code", "li_name", dt, true);
  661. }
  662. private void ComboxDeviceStatusLC_SelectedIndexChanged(object sender, EventArgs e)
  663. {
  664. DeviceStatusQuerySQL.Clear();
  665. string WC = BaseUtil.GetComboxEditValue(ComboxDeviceStatusWC);
  666. string LC = BaseUtil.GetComboxEditValue(ComboxDeviceStatusLC);
  667. if (CheckEditDeviceStatusEnable.Checked)
  668. {
  669. DeviceStatusQuerySQL.Append("select distinct de_code,de_name,dpc_status,dpc_id from device left join ");
  670. DeviceStatusQuerySQL.Append("DEVICEPOLLINGCONFIG on dpc_decode=de_code where nvl(dpc_enable,0)<>0");
  671. if (WC != "全部")
  672. DeviceStatusQuerySQL.Append(" and de_wccode='" + WC + "' ");
  673. if (LC != "全部")
  674. DeviceStatusQuerySQL.Append(" and de_linecode='" + LC + "' ");
  675. DeviceStatusQuerySQL.Append(" order by de_code");
  676. }
  677. else
  678. {
  679. DeviceStatusQuerySQL.Append("select distinct de_code,de_name,dpc_status,dpc_id from device left join ");
  680. DeviceStatusQuerySQL.Append("DEVICEPOLLINGCONFIG on dpc_decode=de_code ");
  681. if (WC != "全部" && LC != "全部")
  682. DeviceStatusQuerySQL.Append(" where de_wccode='" + WC + "' and de_linecode='" + LC + "' ");
  683. if (WC == "全部" && LC != "全部")
  684. DeviceStatusQuerySQL.Append(" where de_linecode='" + LC + "' ");
  685. if (WC != "全部" && LC == "全部")
  686. DeviceStatusQuerySQL.Append(" where de_wccode='" + WC + "' ");
  687. DeviceStatusQuerySQL.Append("order by de_code");
  688. }
  689. PaintDeviceStatusControl(DeviceStatusQuerySQL.ToString());
  690. }
  691. private void PaintDeviceStatusControl(string SQL)
  692. {
  693. DataTable dt = (DataTable)dh.ExecuteSql(SQL, "select");
  694. //界面重新展示时如过数量不一致则重新绘制
  695. if (PanelDeviceStatus.Controls.Count != dt.Rows.Count)
  696. {
  697. PanelDeviceStatus.Controls.Clear();
  698. int CountPerRow = PanelDeviceStatus.Width / 110;
  699. int RightPadding = PanelDeviceStatus.Width % 110;
  700. int Count = dt.Rows.Count;
  701. int RowCount = Count % CountPerRow == 0 ? Count / CountPerRow : Count / CountPerRow + 1;
  702. int LastRowCount = 0;
  703. for (int i = 0; i < PanelDeviceStatus.Controls.Count; i++)
  704. {
  705. PanelDeviceStatus.Controls[i].Dispose();
  706. }
  707. ContextMenu ContextMenu = new ContextMenu();
  708. for (int j = 0; j < RowCount; j++)
  709. {
  710. //如果是最后一行则循环尾数
  711. if (j == RowCount - 1)
  712. {
  713. LastRowCount = Count % CountPerRow;
  714. }
  715. for (int i = 0; i < (j == RowCount - 1 ? LastRowCount : CountPerRow); i++)
  716. {
  717. PictureEditWithText pic = new PictureEditWithText();
  718. pic.DeviceName = dt.Rows[j * CountPerRow + i]["de_name"].ToString();
  719. pic.Picedit.ToolTipController = CommonTipController;
  720. pic.Picedit.ContextMenu = ContextMenu;
  721. pic.Picedit.Click += Pic_Click;
  722. pic.Name = dt.Rows[j * CountPerRow + i]["de_code"].ToString() + i + j;
  723. pic.Anchor = AnchorStyles.Left;
  724. pic.Anchor = AnchorStyles.Top;
  725. pic.Picedit.Name = dt.Rows[j * CountPerRow + i]["de_code"].ToString();
  726. pic.Picedit.MouseHover += Pic_MouseHover;
  727. pic.Picedit.Properties.SizeMode = PictureSizeMode.Squeeze;
  728. if (dt.Rows[j * CountPerRow + i]["dpc_status"].ToString() != "Running")
  729. {
  730. pic.Picedit.Image = Properties.Resources.network_offline;
  731. }
  732. else
  733. {
  734. pic.Picedit.Image = Properties.Resources.net_connected;
  735. }
  736. pic.Text = dt.Rows[j * CountPerRow + i]["de_code"].ToString();
  737. pic.Picedit.BorderStyle = BorderStyles.HotFlat;
  738. pic.Location = new Point((10 + RightPadding) / 2 + 110 * i, 10 + j * 150);
  739. PanelDeviceStatus.Controls.Add(pic);
  740. }
  741. }
  742. BaseUtil.CleanMemory();
  743. TimerDeviceStatus.Start();
  744. }
  745. }
  746. private void Pic_Click(object sender, EventArgs e)
  747. {
  748. PictureEdit pic = sender as PictureEdit;
  749. DeviceStatusInfo dsi = new DeviceStatusInfo(pic.Name);
  750. dsi.StartPosition = FormStartPosition.CenterScreen;
  751. dsi.ShowDialog();
  752. }
  753. private void Pic_MouseHover(object sender, EventArgs e)
  754. {
  755. //使用Tip显示轮询数据
  756. PictureEdit pic = sender as PictureEdit;
  757. DataTable dt = (DataTable)dh.ExecuteSql("select * from DEVICEPOLLINGLOG where dpg_id=(select max(dpg_id) from DEVICEPOLLINGLOG where dpg_decode='" + pic.Name + "')", "select");
  758. if (dt.Rows.Count > 0)
  759. {
  760. sql.Clear();
  761. sql.Append("开始时间" + dt.Rows[0]["dpg_starttime"].ToString() + "\n");
  762. sql.Append("发送数据大小" + dt.Rows[0]["dpg_senddatasize"].ToString() + "字节\n");
  763. sql.Append("接收数据大小" + dt.Rows[0]["dpg_receivedatasize"].ToString() + "字节\n");
  764. sql.Append("轮询次数" + dt.Rows[0]["dpg_count"].ToString() + "次\n");
  765. CommonTipController.ShowHint(sql.ToString(), pic.Name);
  766. }
  767. else
  768. {
  769. CommonTipController.ShowHint("暂无信息", pic.Name);
  770. }
  771. }
  772. //重新展示设备图像界面
  773. private void ShowDeviceStatus()
  774. {
  775. DataTable dt = (DataTable)dh.ExecuteSql(DeviceStatusQuerySQL.ToString(), "select");
  776. int CountPerRow = PanelDeviceStatus.Width / 110;
  777. int RightPadding = PanelDeviceStatus.Width % 110;
  778. int Count = dt.Rows.Count;
  779. int RowCount = Count % CountPerRow == 0 ? Count / CountPerRow : Count / CountPerRow + 1;
  780. int LastRowCount = 0;
  781. //只更换现有控件的图片,不必重新绘制控件
  782. for (int j = 0; j < RowCount; j++)
  783. {
  784. //如果是最后一行则循环尾数
  785. if (j == RowCount - 1)
  786. {
  787. LastRowCount = Count % CountPerRow;
  788. }
  789. for (int i = 0; i < (j == RowCount - 1 ? LastRowCount : CountPerRow); i++)
  790. {
  791. if (dt.Rows[j * CountPerRow + i]["dpc_status"].ToString() != "Running")
  792. {
  793. (PanelDeviceStatus.Controls[dt.Rows[j * CountPerRow + i]["de_code"].ToString() + i + j] as PictureEditWithText).Picedit.Image = Properties.Resources.network_offline;
  794. }
  795. else
  796. {
  797. (PanelDeviceStatus.Controls[dt.Rows[j * CountPerRow + i]["de_code"].ToString() + i + j] as PictureEditWithText).Picedit.Image = Properties.Resources.net_connected;
  798. }
  799. }
  800. }
  801. BaseUtil.CleanMemory();
  802. }
  803. //刷新界面
  804. private void TimerDeviceStatus_Tick(object sender, EventArgs e)
  805. {
  806. if (PageDeviceStatus.PageVisible)
  807. {
  808. ShowDeviceStatus();
  809. }
  810. }
  811. private void PanelDeviceStatus_SizeChanged(object sender, EventArgs e)
  812. {
  813. if (PageDeviceStatus.PageVisible)
  814. {
  815. ShowDeviceStatus();
  816. TimerDeviceStatus.Start();
  817. }
  818. }
  819. #endregion
  820. }
  821. }