init: 潍柴发动机线 中央控制程序 项目首次入库
This commit is contained in:
187
SCADA/MainGuide/MW.Event.cs
Normal file
187
SCADA/MainGuide/MW.Event.cs
Normal file
@@ -0,0 +1,187 @@
|
||||
using SlMesDbIterface;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using DC_A95;
|
||||
using ExternalDataSync;
|
||||
using MainLineRepair;
|
||||
using NPOITest;
|
||||
|
||||
namespace MesWork
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public partial class Temp { }
|
||||
/// <summary>
|
||||
/// 事件处理
|
||||
/// </summary>
|
||||
public partial class MesWorkForm
|
||||
{
|
||||
/// <summary>
|
||||
/// 打开监控界面
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void label_Monitor_PLC_Click(object sender, EventArgs e)
|
||||
{
|
||||
new OpcForm(IsDemoMesServer).Show(this);
|
||||
}
|
||||
/// <summary>
|
||||
/// 关闭按钮
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void label_ExitSys_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (MessageBox.Show("是否确认退出程序?", "退出", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
|
||||
{
|
||||
timer_OnLine_Show.Enabled = false;
|
||||
timer_ShowStation.Enabled = false;
|
||||
|
||||
CloseDeviceConn();
|
||||
//StopServer();
|
||||
LogRecord.LogRecord.Insert_Log(Type_Log.Login, "", "退出MES系统!!!!");
|
||||
System.Diagnostics.Process.GetCurrentProcess().Kill();
|
||||
}
|
||||
}
|
||||
|
||||
private void label_PlanManage_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
var planquery = new PlanExecute_Query.PlanExecute();
|
||||
planquery.ShowDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 鼠标移动
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void C_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
|
||||
{
|
||||
if (allowDrag & isMouseDown)
|
||||
{
|
||||
var control = (Control)sender;
|
||||
int left = control.Left + e.X - mouseOffset.X;
|
||||
int top = control.Top + e.Y - mouseOffset.Y;
|
||||
control.Location = new Point(left, top);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 打开调试界面
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void label_Test_RW_Click(object sender, EventArgs e)
|
||||
{
|
||||
new F_TestPage().Show(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开监控画面
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Panel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (MesWorkForm.allowDrag)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var panel = (Panel)sender;
|
||||
var stationName = panel.Tag.ToString();
|
||||
if (!MesWorkForm.list_OpenForm.Contains(stationName))
|
||||
{
|
||||
var stationShow = new TagDataEngineStatusShowDialog(stationName);
|
||||
stationShow.Show(this);
|
||||
MesWorkForm.list_OpenForm.Add(stationName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查看消息提示
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Panel_MouseHover(object sender, EventArgs e)
|
||||
{
|
||||
var panel = (Panel)sender;
|
||||
new ToolTip().SetToolTip(panel, panel.Tag.ToString());
|
||||
}
|
||||
/// <summary>
|
||||
/// 打开日志
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void btn_QueryLog_Click(object sender, EventArgs e)
|
||||
{
|
||||
new LogRecord.LogRecord(this.Width, this.Height).Show(this);
|
||||
}
|
||||
/// <summary>
|
||||
/// 保存布局
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void btn_SaveLyout_Click(object sender, EventArgs e)
|
||||
{
|
||||
FuncOperation.SaveLyout();
|
||||
}
|
||||
/// <summary>
|
||||
/// 打开参数配置
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void label_ParamConfig_Click(object sender, EventArgs e)
|
||||
{
|
||||
new ParamConfigPage().ShowDialog();
|
||||
}
|
||||
/// <summary>
|
||||
/// 按下鼠标
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void C_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
mouseOffset.X = e.X;
|
||||
mouseOffset.Y = e.Y;
|
||||
isMouseDown = true;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 抬起鼠标
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void C_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
isMouseDown = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 工位管理
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void label_StationManage_Click(object sender, System.EventArgs e)
|
||||
{
|
||||
var dlg = new F_StationManage();
|
||||
dlg.ShowDialog();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
92
SCADA/MainGuide/MW.Lyout.cs
Normal file
92
SCADA/MainGuide/MW.Lyout.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using SlMesDbIterface;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
|
||||
namespace MesWork
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public partial class Temp { }
|
||||
/// <summary>
|
||||
/// 布局
|
||||
/// </summary>
|
||||
public partial class MesWorkForm
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 添加布局
|
||||
/// </summary>
|
||||
public void ReLoadStationIcon()
|
||||
{
|
||||
ht_Station_Content = new Hashtable();
|
||||
ht_Station_Label = new Hashtable();
|
||||
G_DC_IP_OP = new Dictionary<String, List<String>>();
|
||||
|
||||
ExecuteDB.Select_Station(out DataTable dt);
|
||||
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
var 工位号 = dt.Rows[i]["工位号"].ToString();
|
||||
var 工位名称 = dt.Rows[i]["工位名称"].ToString();
|
||||
var PLC = dt.Rows[i]["PLC"].ToString();
|
||||
var PLC代码 = dt.Rows[i]["PLC代码"].ToString();
|
||||
var PX = Convert.ToInt32(dt.Rows[i]["PX"]);
|
||||
var PY = Convert.ToInt32(dt.Rows[i]["PY"]);
|
||||
var PX_T = Convert.ToInt32(dt.Rows[i]["PX_T"]);
|
||||
var PY_T = Convert.ToInt32(dt.Rows[i]["PY_T"]);
|
||||
var 控件启用 = dt.Rows[i]["控件启用"].ToString().ToLower();
|
||||
|
||||
if (控件启用 == "1" | 控件启用 == "true")
|
||||
{
|
||||
SetMember(工位号, Release(new Panel()
|
||||
{
|
||||
Location = new System.Drawing.Point(PX, PY),
|
||||
Size = new Size(30, 30),
|
||||
BackColor = color_Bad,
|
||||
Tag = 工位号,
|
||||
BorderStyle = BorderStyle.Fixed3D
|
||||
}));
|
||||
SetMember(工位号, Release(new Label()
|
||||
{
|
||||
Location = new System.Drawing.Point(PX_T, PY_T),
|
||||
Size = new Size(35, 25),
|
||||
Text = 工位号.Replace("OP", "")
|
||||
}));
|
||||
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (G_DC_IP_OP.ContainsKey(PLC))
|
||||
{
|
||||
G_DC_IP_OP[PLC].Add(工位号);
|
||||
}
|
||||
else
|
||||
{
|
||||
var list = new List<String>();
|
||||
list.Add(工位号);
|
||||
G_DC_IP_OP.Add(PLC, list);
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
197
SCADA/MainGuide/MW.OnStart.cs
Normal file
197
SCADA/MainGuide/MW.OnStart.cs
Normal file
@@ -0,0 +1,197 @@
|
||||
using DC_A95;
|
||||
using DC_A95.MES_A95;
|
||||
using MesToMs;
|
||||
using SlMesDbIterface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using SystemFramework;
|
||||
using WebApi;
|
||||
|
||||
namespace MesWork
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public partial class Temp { }
|
||||
/// <summary>
|
||||
/// 程式启动
|
||||
/// </summary>
|
||||
public partial class MesWorkForm
|
||||
{
|
||||
InitServer initServer = null;
|
||||
/// <summary>
|
||||
/// 从这里启动
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
protected override void OnShown(EventArgs e)
|
||||
{
|
||||
//【0】基础信息检查
|
||||
SqlOperation.ExecuteSql("select getdate()", out DataTable dt, out string error);
|
||||
if (error.Length > 0)
|
||||
{
|
||||
MessageBox.Show($"数据库配置错误!请检查数据库连接!!\r\n\r\n{MesWorkForm.ConnectionString}");
|
||||
Process.GetCurrentProcess().Kill();
|
||||
}
|
||||
|
||||
DataLinkMesWork.ApplicationConfig.ConnectionString_MES = MesWorkForm.ConnectionString;
|
||||
label_SqlConn.Text = MesWorkForm.ConnectionString;
|
||||
|
||||
//【1】系统基本参数设定
|
||||
ThreadPool.SetMaxThreads(workerThreads, completionPortThreads);
|
||||
Never_Know.Hello_You_All_Never_Know = Hello_You_All_Never_Know;
|
||||
new ApplicationLog();
|
||||
|
||||
//【2】初始化
|
||||
ReLoadStationIcon();
|
||||
Visible_SaveLyoutBtn(false);
|
||||
Hanger.Load_Station_PageShowSignal();
|
||||
|
||||
//【3】创建通讯
|
||||
LoadOpcData();
|
||||
Hanger.Load_Table();
|
||||
// LoadOPCData(BasicDataTableFile, IsDemoMesServer, IsWriteMonitorLog, true);
|
||||
Thread.Sleep(200);
|
||||
StartServer();
|
||||
Thread.Sleep(200);
|
||||
First_TagMonitor();
|
||||
//var onList = CheckDeviceOnLine();
|
||||
|
||||
//【4】检查在线状态
|
||||
CommunicationCheckOnLine();
|
||||
|
||||
//【5】通讯成功的初始化设备数据
|
||||
timer_OnLine_Show.Interval = 1000;
|
||||
timer_OnLine_Show.Enabled = true;
|
||||
timer_ShowStation.Interval = 1000;
|
||||
timer_ShowStation.Enabled = true;
|
||||
|
||||
//【7】HashTable 加载TaskType
|
||||
Upload_TaskTypeInfo();
|
||||
|
||||
var task1 = new Thread(new ThreadStart(Loop));
|
||||
task1.IsBackground = true;
|
||||
task1.Start();
|
||||
|
||||
Text = Text + $"【{MesWorkForm.ProgramPartial}】";
|
||||
|
||||
// 【8】 WebApi 相关
|
||||
initServer = new WebApi.InitServer(MesWorkForm.WebSvrPort);
|
||||
|
||||
LogRecord.LogRecord.Insert_Log(Type_Log.Login,"", $"MES系统启动成功!");
|
||||
}
|
||||
|
||||
|
||||
private void Upload_TaskTypeInfo()
|
||||
{
|
||||
ht_TaskTypeInfo=new System.Collections.Hashtable();
|
||||
DataTable dt = ExecuteDB.Get_TaskTypeInfo();
|
||||
foreach (DataRow itemRow in dt.Rows)
|
||||
{
|
||||
TaskTypeInfo taskTypeInfo = new TaskTypeInfo();
|
||||
taskTypeInfo.TaskTypeID = short.Parse(itemRow["任务类型"].ToString());
|
||||
taskTypeInfo.TaskTypeName = itemRow["任务类型名称"].ToString();
|
||||
taskTypeInfo.QCDataCount = int.Parse(itemRow["质量数据数量"].ToString());
|
||||
taskTypeInfo.DataName1 = itemRow["数据名称1"].ToString();
|
||||
taskTypeInfo.DataUnit1 = itemRow["数据单位1"].ToString();
|
||||
taskTypeInfo.DataName2 = itemRow["数据名称2"].ToString();
|
||||
taskTypeInfo.DataUnit2 = itemRow["数据单位2"].ToString();
|
||||
taskTypeInfo.DataName3 = itemRow["数据名称3"].ToString();
|
||||
taskTypeInfo.DataUnit3 = itemRow["数据单位3"].ToString();
|
||||
taskTypeInfo.DataName4 = itemRow["数据名称4"].ToString();
|
||||
taskTypeInfo.DataUnit4 = itemRow["数据单位4"].ToString();
|
||||
ht_TaskTypeInfo.Add(taskTypeInfo.TaskTypeID,taskTypeInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void LoadOpcData()
|
||||
{
|
||||
DataTable dt_Tag = null;
|
||||
|
||||
ExecuteDB.Select_Station(out DataTable dt_Station);
|
||||
dt_OPNameInfo = dt_Station.Copy();
|
||||
int tableLength = NPOITest.ExeclHelper.ExcelToDataTable(BasicDataTableFile, "MES_基本变量原始数据", true).Select($"是否启用='1'").Length;
|
||||
var dt_Tag_Mes = new DataTable();
|
||||
if (tableLength > 0)
|
||||
{
|
||||
dt_Tag_Mes = NPOITest.ExeclHelper.ExcelToDataTable(BasicDataTableFile, "MES_基本变量原始数据", true).Select($"是否启用='1'").CopyToDataTable();
|
||||
}
|
||||
var dt_Tag_Model = NPOITest.ExeclHelper.ExcelToDataTable(BasicDataTableFile, "MES_信号表模板", true).Select($"是否启用='1'").CopyToDataTable();
|
||||
var dt_Device = NPOITest.ExeclHelper.ExcelToDataTable(BasicDataTableFile, "设备类型对应表", true).Select($"是否启用='1'").CopyToDataTable();
|
||||
dt_Tag = dt_Tag_Model.Clone();
|
||||
|
||||
for (int i = 0; i < dt_Station.Rows.Count; i++)
|
||||
{
|
||||
//[工位号],[工位名称],[PLC],[PLC代码],[PX],[PY],[PX_T],[PY_T],[控件启用]
|
||||
var 工位名称 = dt_Station.Rows[i]["工位名称"].ToString();
|
||||
var PLC = dt_Station.Rows[i]["PLC"].ToString();
|
||||
var stationName = dt_Station.Rows[i]["工位号"].ToString();
|
||||
var DB_NAME = dt_Station.Rows[i]["PLC代码"].ToString();
|
||||
var zoneCode = dt_Station.Rows[i]["区域代码"].ToString();
|
||||
|
||||
|
||||
var dt_Op_QC_DATA = dt_Tag_Model.Copy().Select($"DbName='DB_NAME'").CopyToDataTable();
|
||||
UpdateOpTable(dt_Op_QC_DATA, stationName, 工位名称, PLC, DB_NAME);
|
||||
dt_Tag.Merge(dt_Op_QC_DATA);
|
||||
|
||||
}
|
||||
|
||||
dt_Tag.Merge(dt_Tag_Mes);
|
||||
|
||||
LoadOPCData(dt_Tag, dt_Device, IsDemoMesServer, IsWriteMonitorLog, true, false, out string error);
|
||||
if (error.Length > 0)
|
||||
{
|
||||
MessageBox.Show($"加载信号产生错误,程序不能启动!!错误:{error}");
|
||||
Process.GetCurrentProcess().Kill();
|
||||
}
|
||||
|
||||
|
||||
var dt_Tag1 = dt_Tag.Copy();
|
||||
dt_Tag1.TableName = "MES_基本变量_原始数据";
|
||||
SqlOperation.ExecuteSql($" truncate table {dt_Tag1.TableName}", out string error1);
|
||||
SqlOperation.SqlbulkcopyInsert(dt_Tag1);
|
||||
|
||||
var dt_Device1 = dt_Device.Copy();
|
||||
dt_Device1.TableName = "MES_基本变量设备类型对应表";
|
||||
SqlOperation.ExecuteSql($" truncate table {dt_Device1.TableName}", out string error2);
|
||||
SqlOperation.SqlbulkcopyInsert(dt_Device1);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void UpdateOpTable(DataTable dt,string opName,string opNameName,string ip, string dbName)
|
||||
{
|
||||
|
||||
foreach (DataRow row in dt.Rows)
|
||||
{
|
||||
//TagID TagName 工位号 数据来源 IP DbName 变量特点 变量类型代码
|
||||
|
||||
var TagName = row["TagName"].ToString();
|
||||
var 变量类型代码 = row["变量类型代码"].ToString();
|
||||
var 变量特点 = row["变量特点"].ToString();
|
||||
var 变量排序 = row["变量排序"].ToString();
|
||||
|
||||
row["TagID"] = $"8{opName.Substring(opName.Length - 4, 4)}{变量排序.PadLeft(3,'0')}";
|
||||
//row["TagID"] = Guid.NewGuid().ToString ().ToUpper ();
|
||||
row["工位号"] = opName;
|
||||
row["数据来源"] = opNameName;
|
||||
row["IP"] = ip;
|
||||
row["DbName"] = dbName;
|
||||
|
||||
row["监控组"] = $"{row["监控组"].ToString()}_{opName}";
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
209
SCADA/MainGuide/MW.PageDelayRefresh.cs
Normal file
209
SCADA/MainGuide/MW.PageDelayRefresh.cs
Normal file
@@ -0,0 +1,209 @@
|
||||
using SlMesDbIterface;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace MesWork
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public partial class Temp { }
|
||||
/// <summary>
|
||||
/// 延时刷新
|
||||
/// </summary>
|
||||
public partial class MesWorkForm
|
||||
{
|
||||
/// <summary>
|
||||
/// 刷新
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void timer_OnLine_Show_Tick(object sender, EventArgs e)
|
||||
{
|
||||
timer_OnLine_Show.Enabled = false;
|
||||
|
||||
Show_OnLineState();
|
||||
label_RunSort.Text = $"{RunSort}";
|
||||
|
||||
timer_OnLine_Show.Enabled = true;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取数据库连接状态
|
||||
/// </summary>
|
||||
private void CommunicationCheckOnLine()
|
||||
{
|
||||
//源数据库
|
||||
new Thread(new ThreadStart(delegate ()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
MesWorkForm.OnLine_Sql = SqlOperation.ExecuteSql("select getdate()", out DataTable dt,out string error);
|
||||
}
|
||||
catch (Exception) { }
|
||||
Thread.Sleep(5000);
|
||||
}
|
||||
}))
|
||||
{ IsBackground = true }.Start();
|
||||
}
|
||||
/// <summary>
|
||||
/// 显示通讯状态
|
||||
/// </summary>
|
||||
/// <param name="pb"></param>
|
||||
/// <param name="onLine"></param>
|
||||
private void OnLineState_C(PictureBox pb, bool onLine)
|
||||
{
|
||||
pb.Image = onLine ? global::CentralControl.Properties.Resources.连接状态
|
||||
: global::CentralControl.Properties.Resources.断开状态;
|
||||
}
|
||||
/// <summary>
|
||||
/// 显示通讯状态
|
||||
/// </summary>
|
||||
private void Show_OnLineState()
|
||||
{
|
||||
//状态显示
|
||||
OnLineState_C(pb_OnLine_Sql, MesWorkForm.OnLine_Sql);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 刷新
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void timer_ShowStation_Tick(object sender, EventArgs e)
|
||||
{
|
||||
timer_ShowStation.Enabled = false;
|
||||
|
||||
RefreshShowStation();
|
||||
|
||||
timer_ShowStation.Enabled = true;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 显示工位状态
|
||||
/// </summary>
|
||||
public static void RefreshShowStation()
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (DictionaryEntry item in ht_Station_Content)
|
||||
{
|
||||
var stationName = item.Key.ToString();
|
||||
var control = (Panel)item.Value;
|
||||
|
||||
var auto = ht_Signal__Station_Auto[stationName].ToString().ToLower();
|
||||
var running = ht_Signal__Station_Running[stationName].ToString().ToLower();
|
||||
var manual = ht_Signal__Station_Manual[stationName].ToString().ToLower();
|
||||
var alarm = ht_Signal__Station_Alarm[stationName].ToString().ToLower();
|
||||
var offLine = ht_Signal__Station_OffLine[stationName].ToString().ToLower();
|
||||
|
||||
if (ValueT(offLine))
|
||||
{
|
||||
if (ValueT(auto))
|
||||
{
|
||||
control.BackColor = color_Yellow;
|
||||
}
|
||||
if (ValueT(running))
|
||||
{
|
||||
control.BackColor = color_Green;
|
||||
}
|
||||
if (ValueT(manual))
|
||||
{
|
||||
control.BackColor = color_Faw;
|
||||
}
|
||||
if (ValueT(alarm))
|
||||
{
|
||||
control.BackColor = color_Red;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
control.BackColor = color_Bad;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 值处理函数
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public static bool ValueT(string value)
|
||||
{
|
||||
bool success = false;
|
||||
if (value == "true" | value == "1")
|
||||
{
|
||||
success = true;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
/// <summary>
|
||||
/// 显示报警信息
|
||||
/// 临时!!!!
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void timer_ShowAlarm_Tick(object sender, EventArgs e)
|
||||
{
|
||||
timer_ShowAlarm.Enabled = false;
|
||||
//try
|
||||
//{
|
||||
// var sql =
|
||||
// $" SELECT [StationName],[AlarmCode],[AlarmTime],[SureTime] FROM [SP_Curr_Alarm]" +
|
||||
// $" ORDER BY [ID] DESC";
|
||||
// SqlOperation.ExecuteSql(sql, out DataTable dt_Alarm, out string error);
|
||||
// dgv_Alarm.DataSource = dt_Alarm;
|
||||
//}
|
||||
//catch (Exception err) { }
|
||||
//try
|
||||
//{
|
||||
// var sql =
|
||||
// $" SELECT [StationName],[AlarmCode],[AlarmTime],[SureTime] FROM [SP_Curr_Alarm_Andon]" +
|
||||
// $" ORDER BY [ID] DESC";
|
||||
// SqlOperation.ExecuteSql(sql, out DataTable dt_Alarm_Andon, out string error);
|
||||
// dgv_Alarm_Andon.DataSource = dt_Alarm_Andon;
|
||||
//}
|
||||
//catch (Exception err) { }
|
||||
|
||||
timer_ShowAlarm.Enabled = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 布局按钮显示
|
||||
/// </summary>
|
||||
/// <param name="visible"></param>
|
||||
public void Visible_SaveLyoutBtn(bool visible)
|
||||
{
|
||||
btn_SaveLyout.Visible = visible;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
62
SCADA/MainGuide/MW.Register.cs
Normal file
62
SCADA/MainGuide/MW.Register.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using SlMesDbIterface;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
|
||||
namespace MesWork
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public partial class Temp { }
|
||||
/// <summary>
|
||||
/// 注册事件
|
||||
/// </summary>
|
||||
public partial class MesWorkForm
|
||||
{
|
||||
/// <summary>
|
||||
/// 注册事件
|
||||
/// </summary>
|
||||
/// <param name="panel"></param>
|
||||
private Control Release(Panel panel)
|
||||
{
|
||||
panel.MouseDown -= C_MouseDown;
|
||||
panel.MouseDown += C_MouseDown;
|
||||
panel.MouseMove -= C_MouseMove;
|
||||
panel.MouseMove += C_MouseMove;
|
||||
panel.MouseUp -= C_MouseUp;
|
||||
panel.MouseUp += C_MouseUp;
|
||||
panel.MouseHover -= Panel_MouseHover;
|
||||
panel.MouseHover += Panel_MouseHover;
|
||||
panel.Click -= Panel_Click;
|
||||
panel.Click += Panel_Click;
|
||||
return panel;
|
||||
}
|
||||
/// <summary>
|
||||
/// 注册事件
|
||||
/// </summary>
|
||||
/// <param name="label"></param>
|
||||
private Control Release(Label label)
|
||||
{
|
||||
label.MouseDown -= C_MouseDown;
|
||||
label.MouseDown += C_MouseDown;
|
||||
label.MouseMove -= C_MouseMove;
|
||||
label.MouseMove += C_MouseMove;
|
||||
label.MouseUp -= C_MouseUp;
|
||||
label.MouseUp += C_MouseUp;
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user