|
@@ -167,16 +167,6 @@ namespace UAS_PLCDataReader
|
|
|
|
|
|
Ptime = new Dictionary<int, PollingTimer>();
|
|
|
}
|
|
|
- /// <summary>
|
|
|
- /// 关闭前将所有设备离线,状态更新为离线
|
|
|
- /// </summary>
|
|
|
- /// <param name="sender"></param>
|
|
|
- /// <param name="e"></param>
|
|
|
- private void Main_FormClosing(object sender, FormClosingEventArgs e)
|
|
|
- {
|
|
|
- dh.ExecuteSql("update devicepollingconfig set dpc_status='Stop' where dpc_status='Running'", "update");
|
|
|
- dh.ExecuteSql("update devicepollinglog set dpg_status='Stop' where dpg_status='Running'", "update");
|
|
|
- }
|
|
|
#endregion
|
|
|
|
|
|
#region 设备列表界面
|
|
@@ -414,17 +404,13 @@ namespace UAS_PLCDataReader
|
|
|
sql.Append("insert into DEVICEPOLLINGLOG(dpg_id,dpg_decode,dpg_starttime,dpg_interval)values");
|
|
|
sql.Append("(DEVICEPOLLINGLOG_seq.nextval,'" + pl.DeviceCode + "',sysdate,'" + pl.Interval + "')");
|
|
|
dh.ExecuteSql(sql.ToString(), "insert");
|
|
|
- sql.Clear();
|
|
|
- sql.Append("MERGE INTO DeviceRunstatus alias1 USING (select '" + pl.DeviceCode + "' dr_decode from dual) alias2 ");
|
|
|
- sql.Append("ON (alias1.dr_decode=alias2.dr_decode) WHEN MATCHED THEN UPDATE SET dr_startdate =sysdate ");
|
|
|
- sql.Append("WHEN NOT MATCHED THEN INSERT (Dr_id,dr_decode,dr_dename,Dr_runstatus,dr_startdate) VALUES (DeviceRunstatus_seq.nextval,");
|
|
|
- sql.Append("'" + pl.DeviceCode + "','" + pl.DeviceName + "','running',sysdate)");
|
|
|
- dh.ExecuteSql(sql.ToString(), "update");
|
|
|
+ LogicHandler.UpdateDeviceStatus(pl.DeviceCode, pl.DeviceName, "running");
|
|
|
pt.AddTask(RunTask, pl);
|
|
|
//添加到状态为运行的行
|
|
|
PollSettingPaintRowIndex.Add(i);
|
|
|
GridPollingSetting.Focus();
|
|
|
}
|
|
|
+ else LogicHandler.UpdateDeviceStatus(pl.DeviceCode, pl.DeviceName, "stopped");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -499,7 +485,7 @@ namespace UAS_PLCDataReader
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- ModBusTCPClient modclient = new ModBusTCPClient(DNC.Rows[0]["dnc_ip"].ToString(), int.Parse(DNC.Rows[0]["dnc_port"].ToString()));
|
|
|
+ ModBusTCPClient modclient = new ModBusTCPClient(DNC.Rows[0]["dnc_ip"].ToString(), int.Parse(DNC.Rows[0]["dnc_port"].ToString()), pl.DeviceCode, pl.DeviceName);
|
|
|
client.Add(DpcID, modclient);
|
|
|
}
|
|
|
//如果不包含该项数据则在键值对中添加
|
|
@@ -665,7 +651,7 @@ namespace UAS_PLCDataReader
|
|
|
if (PageDeviceStatus.PageVisible)
|
|
|
{
|
|
|
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");
|
|
|
+ DeviceStatusQuerySQL.Append("select distinct de_code,de_name,dr_runstatus from device left join devicerunstatus on dr_decode=de_code order by de_code");
|
|
|
PaintDeviceStatusControl(DeviceStatusQuerySQL.ToString());
|
|
|
//填充筛选条件,车间和线体
|
|
|
DataTable dt = (DataTable)dh.ExecuteSql("select wc_code,wc_name from workcenter", "select");
|
|
@@ -678,13 +664,13 @@ namespace UAS_PLCDataReader
|
|
|
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");
|
|
|
+ DeviceStatusQuerySQL.Append("select distinct de_code,de_name,dr_runstatus from device left join devicerunstatus ");
|
|
|
+ DeviceStatusQuerySQL.Append("on dr_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");
|
|
|
+ DeviceStatusQuerySQL.Append("select distinct de_code,de_name,dr_runstatus from device left join devicerunstatus ");
|
|
|
+ DeviceStatusQuerySQL.Append("on dr_decode=de_code order by de_code");
|
|
|
}
|
|
|
PaintDeviceStatusControl(DeviceStatusQuerySQL.ToString());
|
|
|
}
|
|
@@ -695,13 +681,13 @@ namespace UAS_PLCDataReader
|
|
|
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");
|
|
|
+ DeviceStatusQuerySQL.Append("select distinct de_code,de_name,dr_runstatus from device left join devicerunstatus ");
|
|
|
+ DeviceStatusQuerySQL.Append("on dr_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");
|
|
|
+ DeviceStatusQuerySQL.Append("select distinct de_code,de_name,dr_runstatus from device left join devicerunstatus ");
|
|
|
+ DeviceStatusQuerySQL.Append("on dr_decode=de_code where de_wccode='" + WC + "' order by de_code");
|
|
|
}
|
|
|
PaintDeviceStatusControl(DeviceStatusQuerySQL.ToString());
|
|
|
sql.Clear();
|
|
@@ -720,8 +706,8 @@ namespace UAS_PLCDataReader
|
|
|
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");
|
|
|
+ DeviceStatusQuerySQL.Append("select distinct de_code,de_name,dr_runstatus from device left join ");
|
|
|
+ DeviceStatusQuerySQL.Append("devicerunstatus on dr_decode=de_code ");
|
|
|
if (WC != "全部")
|
|
|
DeviceStatusQuerySQL.Append(" and de_wccode='" + WC + "' ");
|
|
|
if (LC != "全部")
|
|
@@ -730,8 +716,8 @@ namespace UAS_PLCDataReader
|
|
|
}
|
|
|
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 ");
|
|
|
+ DeviceStatusQuerySQL.Append("select distinct de_code,de_name,dr_runstatus from device left join ");
|
|
|
+ DeviceStatusQuerySQL.Append("devicerunstatus on dr_decode=de_code ");
|
|
|
if (WC != "全部" && LC != "全部")
|
|
|
DeviceStatusQuerySQL.Append(" where de_wccode='" + WC + "' and de_linecode='" + LC + "' ");
|
|
|
if (WC == "全部" && LC != "全部")
|
|
@@ -781,16 +767,23 @@ namespace UAS_PLCDataReader
|
|
|
pic.Picedit.MouseHover += Pic_MouseHover;
|
|
|
pic.Picedit.Properties.SizeMode = PictureSizeMode.Squeeze;
|
|
|
//如果该设备已启动
|
|
|
- if (ReturnData.ContainsKey(dt.Rows[j * CountPerRow + i]["de_code"].ToString()))
|
|
|
+ switch (dt.Rows[j * CountPerRow + i]["dr_runstatus"].ToString())
|
|
|
{
|
|
|
- if (ReturnData[dt.Rows[j * CountPerRow + i]["de_code"].ToString()].RunStatus == "Running")
|
|
|
- {
|
|
|
- pic.Picedit.Image = Properties.Resources.net_connected;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- pic.Picedit.Image = Properties.Resources.network_offline;
|
|
|
+ case "running":
|
|
|
+ pic.Picedit.Image = Properties.Resources.running;
|
|
|
+ break;
|
|
|
+ case "disconnect":
|
|
|
+ pic.Picedit.Image = Properties.Resources.disconnect;
|
|
|
+ break;
|
|
|
+ case "stopped":
|
|
|
+ pic.Picedit.Image = Properties.Resources.stopped;
|
|
|
+ break;
|
|
|
+ case "noanswer":
|
|
|
+ pic.Picedit.Image = Properties.Resources.noanswer;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ pic.Picedit.Image = Properties.Resources.stopped;
|
|
|
+ break;
|
|
|
}
|
|
|
pic.Text = dt.Rows[j * CountPerRow + i]["de_code"].ToString();
|
|
|
pic.Picedit.BorderStyle = BorderStyles.HotFlat;
|
|
@@ -850,16 +843,23 @@ namespace UAS_PLCDataReader
|
|
|
}
|
|
|
for (int i = 0; i < (j == RowCount - 1 ? LastRowCount : CountPerRow); i++)
|
|
|
{
|
|
|
- if (ReturnData.ContainsKey(dt.Rows[j * CountPerRow + i]["de_code"].ToString()))
|
|
|
- {
|
|
|
- if (ReturnData[dt.Rows[j * CountPerRow + i]["de_code"].ToString()].RunStatus == "Running")
|
|
|
- {
|
|
|
- (PanelDeviceStatus.Controls[dt.Rows[j * CountPerRow + i]["de_code"].ToString() + i + j] as PictureEditWithText).Picedit.Image = Properties.Resources.net_connected;
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
+ switch (dt.Rows[j * CountPerRow + i]["dr_runstatus"].ToString())
|
|
|
{
|
|
|
- (PanelDeviceStatus.Controls[dt.Rows[j * CountPerRow + i]["de_code"].ToString() + i + j] as PictureEditWithText).Picedit.Image = Properties.Resources.network_offline;
|
|
|
+ case "running":
|
|
|
+ (PanelDeviceStatus.Controls[dt.Rows[j * CountPerRow + i]["de_code"].ToString() + i + j] as PictureEditWithText).Picedit.Image = Properties.Resources.running;
|
|
|
+ break;
|
|
|
+ case "disconnect":
|
|
|
+ (PanelDeviceStatus.Controls[dt.Rows[j * CountPerRow + i]["de_code"].ToString() + i + j] as PictureEditWithText).Picedit.Image = Properties.Resources.disconnect;
|
|
|
+ break;
|
|
|
+ case "stopped":
|
|
|
+ (PanelDeviceStatus.Controls[dt.Rows[j * CountPerRow + i]["de_code"].ToString() + i + j] as PictureEditWithText).Picedit.Image = Properties.Resources.stopped;
|
|
|
+ break;
|
|
|
+ case "noanswer":
|
|
|
+ (PanelDeviceStatus.Controls[dt.Rows[j * CountPerRow + i]["de_code"].ToString() + i + j] as PictureEditWithText).Picedit.Image = Properties.Resources.noanswer;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ (PanelDeviceStatus.Controls[dt.Rows[j * CountPerRow + i]["de_code"].ToString() + i + j] as PictureEditWithText).Picedit.Image = Properties.Resources.stopped;
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
}
|