|
|
@@ -9,6 +9,7 @@ using UAS_DeviceMonitor.PublicMethod;
|
|
|
using DevExpress.XtraEditors;
|
|
|
using DevExpress.XtraGrid;
|
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
|
+using System.Timers;
|
|
|
using System.Threading;
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
@@ -167,6 +168,9 @@ namespace UAS_DeviceMonitor
|
|
|
#endregion
|
|
|
|
|
|
#region PagePollingSetting业务代码
|
|
|
+
|
|
|
+ bool PollingSign = false;
|
|
|
+
|
|
|
private void ButtonStartPolling_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
PollingTask pt = new PollingTask();
|
|
|
@@ -176,21 +180,29 @@ namespace UAS_DeviceMonitor
|
|
|
Polling pl = new Polling();
|
|
|
pl.DeviceCode = GridViewPollSetting.GetRowCellValue(i, "DPC_DECODE").ToString();
|
|
|
pl.Interval = int.Parse(GridViewPollSetting.GetRowCellValue(i, "DPC_INTERVAL").ToString());
|
|
|
- pl.Enable = (bool)GridViewPollSetting.GetRowCellValue(i, "DPC_ENABLE");
|
|
|
- pt.AddTask(RunTask, pl);
|
|
|
+ pl.Enable = GridViewPollSetting.GetRowCellValue(i, "DPC_ENABLE").ToString() != "0";
|
|
|
+ if (pl.Enable)
|
|
|
+ pt.AddTask(RunTask, pl);
|
|
|
}
|
|
|
+ PollingSign = true;
|
|
|
pt.StartAllTask();
|
|
|
}
|
|
|
|
|
|
private void RunTask(object i)
|
|
|
{
|
|
|
- Polling pl = (Polling)i;
|
|
|
- //Interval
|
|
|
+ while (PollingSign)
|
|
|
+ {
|
|
|
+ Polling pl = (Polling)i;
|
|
|
+ int Interval = pl.Interval;
|
|
|
+ string Decode = pl.DeviceCode;
|
|
|
+ Thread.Sleep(Interval * 1000);
|
|
|
+ SystemInf.dh.ExecuteSql("insert into DEVICEPOLLINGCONFIG(DPC_ID,DPC_DECODE ,DPC_PLCODE ,DPC_PLNAME ,DPC_INTERVAL ,DPC_DCCODE ,DPC_FUNCTION , DPC_ENABLE,DPC_STATUS ,DPC_REMARK) values(DEVICEPOLLINGCONFIG_seq.nextval,'" + Decode + "','','' ,'' ,'' ,'' , '','' ,'')", "insert");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void ButtonPausePolling_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
-
|
|
|
+ PollingSign = false;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|