|
|
@@ -13,6 +13,7 @@ using System.Threading;
|
|
|
using UAS_DeviceMonitor.CustomerControl.PictureEditWithText;
|
|
|
using System.Windows.Forms;
|
|
|
using DevExpress.XtraEditors.Controls;
|
|
|
+using DevExpress.XtraEditors;
|
|
|
|
|
|
namespace UAS_DeviceMonitor
|
|
|
{
|
|
|
@@ -20,6 +21,8 @@ namespace UAS_DeviceMonitor
|
|
|
{
|
|
|
|
|
|
StringBuilder sql = new StringBuilder();
|
|
|
+
|
|
|
+ StringBuilder DeviceStatusQuerySQL = new StringBuilder();
|
|
|
DataHelper dh;
|
|
|
ModeBusTCPServer mbt = new ModeBusTCPServer();
|
|
|
List<string> SQL = new List<string>();
|
|
|
@@ -328,7 +331,7 @@ namespace UAS_DeviceMonitor
|
|
|
//更新轮询日志状态
|
|
|
sql.Clear();
|
|
|
sql.Append("update DEVICEPOLLINGLOG set dpg_status='Running',dpg_senddatasize=nvl(dpg_senddatasize,0)+" + SendCommandByteSize);
|
|
|
- sql.Append(",dpg_receivedatasize=nvl(dpg_receivedatasize,0)+" + ReceiveCommandByteSize);
|
|
|
+ sql.Append(",dpg_receivedatasize=nvl(dpg_receivedatasize,0)+" + ReceiveCommandByteSize + ",dpg_count=nvl(dpg_count,0)+1 ");
|
|
|
sql.Append(" where dpg_id=(select max(dpg_id) from DEVICEPOLLINGLOG where dpg_decode='" + Decode + "')");
|
|
|
SQL.Add(sql.ToString());
|
|
|
dh.ExecuteSQLTran(SQL.ToArray());
|
|
|
@@ -342,8 +345,9 @@ namespace UAS_DeviceMonitor
|
|
|
SQL.Add(sql.ToString());
|
|
|
//更新轮询日志状态
|
|
|
sql.Clear();
|
|
|
- sql.Append("update DEVICEPOLLINGLOG set dpg_status='Running',dpg_senddatasize=nvl(dpg_senddatasize,0)+" + SendCommandByteSize);
|
|
|
- sql.Append(" where dpg_id=(select max(dpg_id) from DEVICEPOLLINGLOG where dpg_decode='" + Decode + "')");
|
|
|
+ sql.Append("update DEVICEPOLLINGLOG set dpg_status='Running',dpg_senddatasize=nvl(dpg_senddatasize,0)+");
|
|
|
+ sql.Append(SendCommandByteSize + ",dpg_count=nvl(dpg_count,0)+1 ");
|
|
|
+ sql.Append("where dpg_id=(select max(dpg_id) from DEVICEPOLLINGLOG where dpg_decode='" + Decode + "')");
|
|
|
SQL.Add(sql.ToString());
|
|
|
dh.ExecuteSQLTran(SQL.ToArray());
|
|
|
}
|
|
|
@@ -418,59 +422,159 @@ namespace UAS_DeviceMonitor
|
|
|
{
|
|
|
if (PageDeviceStatus.PageVisible)
|
|
|
{
|
|
|
- DataTable dt = (DataTable)dh.ExecuteSql("select distinct de_code,dpc_status,dpc_id from device left join DEVICEPOLLINGCONFIG on dpc_decode=de_code order by de_code", "select");
|
|
|
- //界面重新展示时如过数量不一致则重新绘制
|
|
|
- if (PanelDeviceStatus.Controls.Count != dt.Rows.Count)
|
|
|
+ DeviceStatusQuerySQL.Clear();
|
|
|
+ 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");
|
|
|
+ PaintDeviceStatusControl(DeviceStatusQuerySQL.ToString());
|
|
|
+ //填充筛选条件,车间和线体
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql("select wc_code,wc_name from workcenter", "select");
|
|
|
+ BaseUtil.FillComBoxEditWidthDataTable(ComboxDeviceStatusWC, "wc_name", "wc_code", dt, true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void CheckEditDeviceStatusEnable_CheckedChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ DeviceStatusQuerySQL.Clear();
|
|
|
+ if (CheckEditDeviceStatusEnable.Checked)
|
|
|
+ {
|
|
|
+ DeviceStatusQuerySQL.Append("select distinct de_code,de_name,dpc_status,dpc_id from device left join DEVICEPOLLINGCONFIG ");
|
|
|
+ DeviceStatusQuerySQL.Append("on dpc_decode=de_code where nvl(dpc_enable,0)<>0 order by de_code");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DeviceStatusQuerySQL.Append("select distinct de_code,de_name,dpc_status,dpc_id from device left join DEVICEPOLLINGCONFIG ");
|
|
|
+ DeviceStatusQuerySQL.Append("on dpc_decode=de_code order by de_code");
|
|
|
+ }
|
|
|
+ PaintDeviceStatusControl(DeviceStatusQuerySQL.ToString());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void ComboxDeviceStatusWC_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ DeviceStatusQuerySQL.Clear();
|
|
|
+ string WC = BaseUtil.GetComboxEditValue(ComboxDeviceStatusWC);
|
|
|
+ if (CheckEditDeviceStatusEnable.Checked)
|
|
|
+ {
|
|
|
+ DeviceStatusQuerySQL.Append("select distinct de_code,de_name,dpc_status,dpc_id from device left join DEVICEPOLLINGCONFIG ");
|
|
|
+ DeviceStatusQuerySQL.Append("on dpc_decode=de_code where nvl(dpc_enable,0)<>0 and de_wccode='" + WC + "' order by de_code");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DeviceStatusQuerySQL.Append("select distinct de_code,de_name,dpc_status,dpc_id from device left join DEVICEPOLLINGCONFIG ");
|
|
|
+ DeviceStatusQuerySQL.Append("on dpc_decode=de_code where de_wccode='" + WC + "' order by de_code");
|
|
|
+ }
|
|
|
+ PaintDeviceStatusControl(DeviceStatusQuerySQL.ToString());
|
|
|
+ sql.Clear();
|
|
|
+ if (WC == "全部")
|
|
|
+ sql.Append("select li_code,li_name from line");
|
|
|
+ else
|
|
|
+ sql.Append("select li_code,li_name from line where li_wccode='" + WC + "'");
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
|
|
|
+ BaseUtil.FillComBoxEditWidthDataTable(ComboxDeviceStatusLC, "li_code", "li_name", dt, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void ComboxDeviceStatusLC_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ DeviceStatusQuerySQL.Clear();
|
|
|
+ string WC = BaseUtil.GetComboxEditValue(ComboxDeviceStatusWC);
|
|
|
+ string LC = BaseUtil.GetComboxEditValue(ComboxDeviceStatusLC);
|
|
|
+ if (CheckEditDeviceStatusEnable.Checked)
|
|
|
+ {
|
|
|
+ DeviceStatusQuerySQL.Append("select distinct de_code,de_name,dpc_status,dpc_id from device left join ");
|
|
|
+ DeviceStatusQuerySQL.Append("DEVICEPOLLINGCONFIG on dpc_decode=de_code where nvl(dpc_enable,0)<>0");
|
|
|
+ if (WC != "全部")
|
|
|
+ DeviceStatusQuerySQL.Append(" and de_wccode='" + WC + "' ");
|
|
|
+ if (LC != "全部")
|
|
|
+ DeviceStatusQuerySQL.Append(" and de_linecode='"+LC+"' ");
|
|
|
+ DeviceStatusQuerySQL.Append(" order by de_code");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ DeviceStatusQuerySQL.Append("select distinct de_code,de_name,dpc_status,dpc_id from device left join ");
|
|
|
+ DeviceStatusQuerySQL.Append("DEVICEPOLLINGCONFIG on dpc_decode=de_code ");
|
|
|
+ if (WC != "全部")
|
|
|
+ DeviceStatusQuerySQL.Append(" where de_wccode='" + WC + "' ");
|
|
|
+ if (LC != "全部")
|
|
|
+ DeviceStatusQuerySQL.Append(" and de_linecode='" + LC + "' ");
|
|
|
+ DeviceStatusQuerySQL.Append("order by de_code");
|
|
|
+ }
|
|
|
+ PaintDeviceStatusControl(DeviceStatusQuerySQL.ToString());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void PaintDeviceStatusControl(string SQL)
|
|
|
+ {
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql(SQL, "select");
|
|
|
+ //界面重新展示时如过数量不一致则重新绘制
|
|
|
+ if (PanelDeviceStatus.Controls.Count != dt.Rows.Count)
|
|
|
+ {
|
|
|
+ PanelDeviceStatus.Controls.Clear();
|
|
|
+ int CountPerRow = PanelDeviceStatus.Width / 110;
|
|
|
+ int RightPadding = PanelDeviceStatus.Width % 110;
|
|
|
+ int Count = dt.Rows.Count;
|
|
|
+ int RowCount = Count % CountPerRow == 0 ? Count / CountPerRow : Count / CountPerRow + 1;
|
|
|
+ int LastRowCount = 0;
|
|
|
+ for (int i = 0; i < PanelDeviceStatus.Controls.Count; i++)
|
|
|
+ {
|
|
|
+ PanelDeviceStatus.Controls[i].Dispose();
|
|
|
+ }
|
|
|
+ for (int j = 0; j < RowCount; j++)
|
|
|
{
|
|
|
- int CountPerRow = PanelDeviceStatus.Width / 110;
|
|
|
- int RightPadding = PanelDeviceStatus.Width % 110;
|
|
|
- int Count = dt.Rows.Count;
|
|
|
- int RowCount = Count % CountPerRow == 0 ? Count / CountPerRow : Count / CountPerRow + 1;
|
|
|
- int LastRowCount = 0;
|
|
|
- for (int i = 0; i < PanelDeviceStatus.Controls.Count; i++)
|
|
|
+ //如果是最后一行则循环尾数
|
|
|
+ if (j == RowCount - 1)
|
|
|
{
|
|
|
- PanelDeviceStatus.Controls[i].Dispose();
|
|
|
+ LastRowCount = Count % CountPerRow;
|
|
|
}
|
|
|
- for (int j = 0; j < RowCount; j++)
|
|
|
+ for (int i = 0; i < (j == RowCount - 1 ? LastRowCount : CountPerRow); i++)
|
|
|
{
|
|
|
- //如果是最后一行则循环尾数
|
|
|
- if (j == RowCount - 1)
|
|
|
+ PictureEditWithText pic = new PictureEditWithText();
|
|
|
+ pic.DeviceName = dt.Rows[j * CountPerRow + i]["de_name"].ToString();
|
|
|
+ pic.Picedit.ToolTipController = CommonTipController;
|
|
|
+ pic.Name = dt.Rows[j * CountPerRow + i]["de_code"].ToString() + i + j;
|
|
|
+ pic.Anchor = AnchorStyles.Left;
|
|
|
+ pic.Anchor = AnchorStyles.Top;
|
|
|
+ pic.Picedit.Name = dt.Rows[j * CountPerRow + i]["de_code"].ToString();
|
|
|
+ pic.Picedit.MouseHover += Pic_MouseHover;
|
|
|
+ pic.Picedit.Properties.SizeMode = PictureSizeMode.Squeeze;
|
|
|
+ if (dt.Rows[j * CountPerRow + i]["dpc_status"].ToString() != "Running")
|
|
|
{
|
|
|
- LastRowCount = Count % CountPerRow;
|
|
|
+ pic.Picedit.Image = Properties.Resources.network_offline;
|
|
|
}
|
|
|
- for (int i = 0; i < (j == RowCount - 1 ? LastRowCount : CountPerRow); i++)
|
|
|
+ else
|
|
|
{
|
|
|
- PictureEditWithText pic = new PictureEditWithText();
|
|
|
- pic.Name = dt.Rows[j * CountPerRow + i]["de_code"].ToString() + i + j;
|
|
|
- pic.Anchor = AnchorStyles.Left;
|
|
|
- pic.Anchor = AnchorStyles.Top;
|
|
|
- pic.Picedit.Properties.SizeMode = PictureSizeMode.Squeeze;
|
|
|
- if (dt.Rows[j * CountPerRow + i]["dpc_status"].ToString() != "Running")
|
|
|
- {
|
|
|
- CommonTipController.SetToolTip(pic.Picedit, "离线");
|
|
|
- pic.Picedit.Image = Properties.Resources.network_offline;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- CommonTipController.SetToolTip(pic.Picedit, "在线");
|
|
|
- pic.Picedit.Image = Properties.Resources.net_connected;
|
|
|
- }
|
|
|
- pic.Text = dt.Rows[j * CountPerRow + i]["de_code"].ToString();
|
|
|
- pic.Picedit.BorderStyle = BorderStyles.HotFlat;
|
|
|
- pic.Location = new Point((10 + RightPadding) / 2 + 110 * i, 10 + j * 130);
|
|
|
- PanelDeviceStatus.Controls.Add(pic);
|
|
|
+ pic.Picedit.Image = Properties.Resources.net_connected;
|
|
|
}
|
|
|
+ pic.Text = dt.Rows[j * CountPerRow + i]["de_code"].ToString();
|
|
|
+ pic.Picedit.BorderStyle = BorderStyles.HotFlat;
|
|
|
+ pic.Location = new Point((10 + RightPadding) / 2 + 110 * i, 10 + j * 150);
|
|
|
+ PanelDeviceStatus.Controls.Add(pic);
|
|
|
}
|
|
|
- BaseUtil.CleanMemory();
|
|
|
- TimerDeviceStatus.Start();
|
|
|
}
|
|
|
+ BaseUtil.CleanMemory();
|
|
|
+ TimerDeviceStatus.Start();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void Pic_MouseHover(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ PictureEdit pic = sender as PictureEdit;
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql("select * from DEVICEPOLLINGLOG where dpg_id=(select max(dpg_id) from DEVICEPOLLINGLOG where dpg_decode='" + pic.Name + "')", "select");
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ sql.Clear();
|
|
|
+ sql.Append("开始时间" + dt.Rows[0]["dpg_starttime"].ToString() + "\n");
|
|
|
+ sql.Append("发送数据大小" + dt.Rows[0]["dpg_senddatasize"].ToString() + "字节\n");
|
|
|
+ sql.Append("接收数据大小" + dt.Rows[0]["dpg_receivedatasize"].ToString() + "字节\n");
|
|
|
+ sql.Append("轮询次数" + dt.Rows[0]["dpg_count"].ToString() + "次\n");
|
|
|
+ CommonTipController.ShowHint(sql.ToString(), pic.Name);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ CommonTipController.ShowHint("暂无信息", pic.Name);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//重新展示设备图像界面
|
|
|
private void ShowDeviceStatus()
|
|
|
{
|
|
|
- DataTable dt = (DataTable)dh.ExecuteSql("select distinct de_code,dpc_status,dpc_id from device left join DEVICEPOLLINGCONFIG on dpc_decode=de_code order by de_code", "select");
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql(DeviceStatusQuerySQL.ToString(), "select");
|
|
|
int CountPerRow = PanelDeviceStatus.Width / 110;
|
|
|
int RightPadding = PanelDeviceStatus.Width % 110;
|
|
|
int Count = dt.Rows.Count;
|
|
|
@@ -496,6 +600,7 @@ namespace UAS_DeviceMonitor
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ BaseUtil.CleanMemory();
|
|
|
}
|
|
|
|
|
|
//刷新界面
|