chore: 初始化合力差速器MES采集程序

This commit is contained in:
yexingqiang
2026-06-08 10:59:21 +08:00
commit 1591062eef
1379 changed files with 181389 additions and 0 deletions

View File

@@ -0,0 +1,522 @@
//using BasicData;
using DoWhatPlc;
using MesServerWork;
using MisDataFunction;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
//using SystemFramework;
namespace MisDataSaveDate
{
public partial class MisData
{
public void InitFormBtnColor()
{
try
{
if (!Cbx_StatusDisplay.Checked) return;
string OpName = WorkStationNum_Now;
foreach (Control GroupBox in this.groupBox_SignialSimulator.Controls)
{
foreach (Control Btn in GroupBox.Controls)
{
if (Btn.Name.Length < 8) continue;
if (Btn.Name.Substring(0, 8) == "Btn_PLC_" || Btn.Name.Substring(0, 8) == "Btn_MES_")
{
ControlData Ctrl1 = new ControlData(Btn, OpName);
Thread t=new Thread(new ParameterizedThreadStart(InitFormBtn_Thread));
t.Start(Ctrl1);
}
}
}
}
catch (Exception err)
{
//ApplicationLog.WriteLog(err, err.Message);
}
}
static object test;
static void InitFormBtn_Thread(Object obj)
{
try
{
ControlData Btn = (ControlData)obj;
test = DtWebApi.ReadWritePLC.ReadPLC(Btn.TagType.ToString(), Btn.opName);
bool Result = Convert.ToBoolean(test);
if (Btn.btn.InvokeRequired)
{
Action<System.Drawing.Color> actionDelegate = (x) => { Btn.btn.BackColor = x; };
if (Result)
{
Btn.btn.BeginInvoke(actionDelegate, System.Drawing.Color.Green);
}
else
{
Btn.btn.BeginInvoke(actionDelegate, System.Drawing.Color.SlateGray);
}
}
else
{
if (Result)
{
Btn.btn.BackColor = System.Drawing.Color.Green;
}
else
{
Btn.btn.BackColor = System.Drawing.Color.SlateGray;
}
}
}
catch (Exception err)
{
ControlData Btn = (ControlData)obj;
//ApplicationLog.WriteLog(err, err.Message+"采集数据值:"+ ";按钮名称:"+test+ Btn.btn .Name +"工位号"+ WorkStationNum_Now);
}
}
/// <summary>
/// 通过点击界面按钮写入Bool信号
/// </summary>
/// <param name="tagType"></param>
/// <param name="opName"></param>
private void WriteBoolSignalByFormBtn(Object Sender)
{
try
{
string BtnName = ((System.Windows.Forms.Control)Sender).Name;
string[] Array_BtnNameSplit = BtnName.Split('_');
int tagType = Convert.ToInt32(Array_BtnNameSplit[2]);
string OpName = WorkStationNum_Now;
QualityDataQueryStruct QualityQueryStruct = new QualityDataQueryStruct(OpName, tagType);
Thread t = new Thread(new ParameterizedThreadStart(WriteBoolSignal_Thread));
t.Start(QualityQueryStruct);
}
catch (Exception err)
{
//ApplicationLog.WriteLog(err, err.Message);
}
}
void WriteBoolSignal_Thread(object obj)
{
try
{
QualityDataQueryStruct QDQ = (QualityDataQueryStruct)obj;
if (IsDemoMesServer==1)
{
string tagValueStr = "";
MIS_BASE.Read_TagTypeID(QDQ.tagType, QDQ.OpName, out tagValueStr);
if (tagValueStr=="1")
{
tagValueStr = "True";
}
else if (tagValueStr == "0")
{
tagValueStr = "False";
}
bool ReadResult = Convert.ToBoolean(tagValueStr);
if (ReadResult)
{
MIS_BASE.Write_TagTypeID(QDQ.tagType, QDQ.OpName, false);
}
else
{
MIS_BASE.Write_TagTypeID(QDQ.tagType, QDQ.OpName, true);
}
}
else
{
bool ReadResult = Convert.ToBoolean(DtWebApi.ReadWritePLC.ReadPLC(QDQ.tagType.ToString(), QDQ.OpName));
if (ReadResult)
{
DtWebApi.ReadWritePLC.WritePLC(QDQ.tagType.ToString(), QDQ.OpName, false);
}
else
{
DtWebApi.ReadWritePLC.WritePLC(QDQ.tagType.ToString(), QDQ.OpName, true);
}
}
}
catch (Exception err)
{
//ApplicationLog.WriteLog(err, err.Message);
}
}
/// <summary>
/// 写入机型
/// </summary>
/// <param name="Sender"></param>
private void WriteNormalDataBygroupBox_SignialSimulatorWriteBtn(object Sender)
{
try
{
string BtnName = ((System.Windows.Forms.Control)Sender).Name;
string OpName = WorkStationNum_Now;
if (BtnName == "Btn_Write_PLC")
{
foreach (Control Tbx in this.groupBox_PLC.Controls)
{
if (Tbx.Name.Length < 12) continue;
if (Tbx.Name.Substring(0, 8) != "Tbx_PLC_") continue;
string[] TbxName_Split = Tbx.Name.Split('_');
int TagType = Convert.ToInt32(TbxName_Split[2]);
HashtableList htList = DtWebApi.OpcDemo.GetHashtableList();
int tagDataType = Convert.ToInt32(htList.hashtable_TagTypeDataType[TagType.ToString()]);
string tagValue = Tbx.Text.Trim();
short tagValue_int;
string tagValue_str;
byte tagValue_byte;
bool tagValue_bool;
switch (tagDataType)
{
case 2:
if (!Regex.IsMatch(tagValue, @"^[-]?\d*$"))
{
MessageBox.Show("文本框\"" + Tbx.Name + "\"输入不是整数!");
return;
}
if (tagValue == "") return;
tagValue_int = Convert.ToInt16(tagValue);
WriteAnyData_Thread(TagType, OpName, tagValue_int);
break;
case 8:
tagValue_str = tagValue.ToString();
WriteAnyData_Thread(TagType, OpName, tagValue_str);
break;
case 17:
if (!Regex.IsMatch(tagValue, @"^[-]?\d*$"))
{
MessageBox.Show("文本框\"" + Tbx.Name + "\"输入不是整数!");
return;
}
if (Convert.ToInt32(tagValue) > 255)
{
MessageBox.Show("文本框\"" + Tbx.Name + "\"输入数据不在范围内");
return;
}
if (tagValue == "") return;
tagValue_byte = Convert.ToByte(tagValue);
WriteAnyData_Thread(TagType, OpName, tagValue_byte);
break;
case 11:
tagValue_bool = Convert.ToBoolean(Convert.ToInt32(tagValue));
WriteAnyData_Thread(TagType, OpName, tagValue_bool);
break;
default:
tagValue_str = tagValue.ToString();
WriteAnyData_Thread(TagType, OpName, tagValue_str);
break;
}
}
}
else if (BtnName == "Btn_Write_MES")
{
foreach (Control Tbx in this.groupBox_MES.Controls)
{
if (Tbx.Name.Length < 12) continue;
if (Tbx.Name.Substring(0, 8) != "Tbx_MES_") continue;
string[] TbxName_Split = Tbx.Name.Split('_');
int TagType = Convert.ToInt32(TbxName_Split[2]);
HashtableList htList = DtWebApi.OpcDemo.GetHashtableList();
int tagDataType = Convert.ToInt32(htList.hashtable_TagTypeDataType[TagType.ToString()]);
//int tagDataType = Convert.ToInt32(MesDataFunction.OpcOperation.hashtable_TagTypeDataType[TagType.ToString()]);
string tagValue = Tbx.Text.Trim();
short tagValue_int;
string tagValue_str;
byte tagValue_byte;
bool tagValue_bool;
switch (tagDataType)
{
case 2:
if (!Regex.IsMatch(tagValue, @"^[-]?\d*$"))
{
MessageBox.Show("文本框\"" + Tbx.Name + "\"输入不是整数!");
return;
}
tagValue_int = Convert.ToInt16(tagValue);
WriteAnyData_Thread(TagType, OpName, tagValue_int);
break;
case 8:
tagValue_str = tagValue.ToString();
WriteAnyData_Thread(TagType, OpName, tagValue_str);
break;
case 17:
if (!Regex.IsMatch(tagValue, @"^[-]?\d*$"))
{
MessageBox.Show("文本框\"" + Tbx.Name + "\"输入不是整数!");
return;
}
if (Convert.ToInt32(tagValue) > 255)
{
MessageBox.Show("文本框\"" + Tbx.Name + "\"输入数据不在范围内");
return;
}
tagValue_byte = Convert.ToByte(tagValue);
WriteAnyData_Thread(TagType, OpName, tagValue_byte);
break;
case 11:
tagValue_bool = Convert.ToBoolean(Convert.ToInt32(tagValue));
WriteAnyData_Thread(TagType, OpName, tagValue_bool);
break;
default:
tagValue_str = tagValue.ToString();
WriteAnyData_Thread(TagType, OpName, tagValue_str);
break;
}
}
}
}
catch (Exception err)
{
//ApplicationLog.WriteLog(err, err.Message);
}
}
void WriteAnyData_Thread(int tagType, string opName, object tagValue)
{
try
{
QualityDataQueryStruct QualityStruct = new QualityDataQueryStruct(opName, tagType, tagValue);
Thread t = new Thread(new ParameterizedThreadStart(WriteNormalDataBygroupBox_SignialSimulatorWriteBtn_Thread));
t.Start(QualityStruct);
}
catch (Exception err)
{
//ApplicationLog.WriteLog(err, err.Message);
}
}
void WriteNormalDataBygroupBox_SignialSimulatorWriteBtn_Thread(object obj)
{
try
{
QualityDataQueryStruct QualityStruct = (QualityDataQueryStruct)obj;
MIS_BASE.WritePLC(QualityStruct.tagType, QualityStruct. OpName, QualityStruct.tagValue);
}
catch (Exception err)
{
//ApplicationLog.WriteLog(err, err.Message);
}
}
/// <summary>
/// 根据工位号查询质量数据,返回质量数据列表
/// </summary>
/// <param name="opName"></param>
/// <returns></returns>
QualityDataType[] ReadPLC_ValueListForQualityDataTypeArray(string opName)
{
try
{
int i1 = 0;
Hashtable valueList;
valueList = Function.ReadPLC_Sync_DataList_MesRead(opName);
if (valueList != null)
{
QualityDataType[] QualityValue = new QualityDataType[valueList.Count];
foreach (DictionaryEntry de in valueList)
{
try
{
QualityValue[i1] = (QualityDataType)de.Value;
i1++;
}
catch (Exception err)
{
//ApplicationLog.WriteLog(err, err.Message);
}
}
//ThisWorkStationData = QualityValue;
return QualityValue;
}
return null;
}
catch (Exception err)
{
//ApplicationLog.WriteLog(err, err.Message);
return null;
}
}
//public QualityDataType[] ThisWorkStationData
//{ get; set; }
//object QueryThisWorkStationDataByTagTypeFromThisWorkStationDataProperty(int TagType)
//{
//try
//{
// foreach (QualityDataType Data in ThisWorkStationData)
// {
// if (Data.tagValueType == TagType)
// {
// return Data.tagValue;
// }
// }
// return null;
//}
//catch (Exception err)
//{
// ApplicationLog.WriteLog(err, err.Message);
// return null;
//}
//}
void RefreshBtnColor(object obj)
{
try
{
ControlChangeByTagType ControlValue = (ControlChangeByTagType)obj;
if (!Cbx_StatusDisplay.Checked) return;
string OpName = WorkStationNum_Now;
foreach (Control GroupBox in this.groupBox_SignialSimulator.Controls)
{
foreach (Control Btn in GroupBox.Controls)
{
if (Btn.Name.Length < 8) continue;
if (Btn.Name.Substring(0, 8) == "Btn_PLC_" || Btn.Name.Substring(0, 8) == "Btn_MES_")
{
string BtnName = Btn.Name;
string[] BtnName_SplitArray = BtnName.Split('_');
if (Btn.InvokeRequired)
{
Action<System.Drawing.Color> ActionDelegate = (x) => { Btn.BackColor = x; };
if (Convert.ToInt32(BtnName_SplitArray[2]) == ControlValue.TagType)
{
if (ControlValue.Value == "1")
{
Btn.BeginInvoke(ActionDelegate, System.Drawing.Color.Green);
}
else
{
Btn.BeginInvoke(ActionDelegate, System.Drawing.Color.LightGray);
}
}
}
else
{
if (Convert.ToInt32(BtnName_SplitArray[2]) == ControlValue.TagType)
{
if (ControlValue.Value == "1")
{
Btn.BackColor = System.Drawing.Color.Green;
}
else
{
Btn.BackColor = System.Drawing.Color.LightGray;
}
}
}
}
}
}
}
catch (Exception err)
{
//ApplicationLog.WriteLog(err, err.Message);
}
}
void RefreshBtnColor_Thread(int TagType, string Value)
{
ControlChangeByTagType ControlValue = new ControlChangeByTagType(TagType, Value);
Thread t = new Thread(new ParameterizedThreadStart(RefreshBtnColor));
t.Start(ControlValue);
}
/// <summary>
/// 按钮颜色还原
/// </summary>
void RefreshBtnColorWriteNull()
{
try
{
string OpName = WorkStationNum_Now;
foreach (Control GroupBox in this.groupBox_SignialSimulator.Controls)
{
foreach (Control Btn in GroupBox.Controls)
{
if (Btn.Name.Length < 8) continue;
if (Btn.Name.Substring(0, 8) == "Btn_PLC_" || Btn.Name.Substring(0, 8) == "Btn_MES_")
{
if (Btn.InvokeRequired)
{
Action<System.Drawing.Color> ActionDelegate = (x) => { Btn.BackColor = x; };
Btn.BeginInvoke(ActionDelegate, System.Drawing.Color.LightGray);
}
else
{
Btn.BackColor = System.Drawing.Color.LightGray;
}
}
}
}
}
catch (Exception err)
{
//ApplicationLog.WriteLog(err, err.Message);
}
}
}
}

1741
Test/MisDataWebFun.Designer.cs generated Normal file

File diff suppressed because it is too large Load Diff

956
Test/MisDataWebFun.cs Normal file
View File

@@ -0,0 +1,956 @@
//using BasicData;
using bizFacade;
//using OpcData;
using System;
using System.Collections;
using System.Data;
using System.Threading;
using System.Windows.Forms;
//using SystemFramework;
using System.Drawing;
//using MesServerWork;
using System.Configuration;
//using MisDataFunction;
using System.Collections.Generic;
using MQTTnet.Client.Connecting;
using MQTTnet.Client.Disconnecting;
using MQTTnet.Client.Receiving;
using System.Linq;
using DoWhatPlc;
/// <summary>
///
/// </summary>
namespace MisDataSaveDate
{
/// <summary>
///
/// </summary>
/// <param name="obj1"></param>
/// <param name="obj2"></param>
public delegate void RefreshForm(object obj1, EventArgs obj2);
/// <summary>
///
/// </summary>
public partial class MisData:Form
{
/// <summary>
///
/// </summary>
public static string BasicDataTableFile = ConfigurationManager.AppSettings["BasicDataTableFile"];
/// <summary>
///
/// </summary>
public static int IsDemoMesServer = Convert.ToInt32(ConfigurationManager.AppSettings["IsDemoMesServer"]);
/// <summary>
///
/// </summary>
public static string MqttUrl = ConfigurationManager.AppSettings["MqttUrl"];
public static string MqttUrlPLC = ConfigurationManager.AppSettings["MqttUrlPLC"];
/// <summary>
///
/// </summary>
public static string MqttTargetTopic = ConfigurationManager.AppSettings["MqttTargetTopic"];
public static string MqttTargetTopicPLC = ConfigurationManager.AppSettings["MqttTargetTopicPLC"];
/// <summary>
///
/// </summary>
public static int IsWriteMonitorLog = Convert.ToInt32(ConfigurationManager.AppSettings["IsWriteMonitorLog"]);
/// <summary>
///
/// </summary>
public static string ConnectionString_MES = ConfigurationManager.AppSettings["ConnectionString_MES"];
/// <summary>
///
/// </summary>
public static int WebApiPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["WebApiPort"]);
/// <summary>
///
/// </summary>
public static RefreshForm MainFormRefresh, TestPlcStatusDel;
/// <summary>
/// 允许使用附加功能的变量只有在系统开始加载Tag时才允许读取PLC数据
/// </summary>
public static bool AllowLoad;
/// <summary>
///
/// </summary>
public MisData()
{
InitializeComponent();
// CheckForIllegalCrossThreadCalls = false;
// this.Cursor = Cursors.WaitCursor;
// TopMost = true;
// Never_Know.Hello_You_All_Never_Know = Hello_You_All_Never_Know;
// new ApplicationLog();
// ThreadPool.SetMaxThreads(1000, 500);
// MIS_BASE.MqttTargetTopic = MqttTargetTopic;
// new DataLinkMesWork.ApplicationConfig();
// DataTable dt_Signal;
// DataTable dt_Device;
// DataTable dt_TagTypeDataType;
// dt_Signal = bizFacade.BaseDataSystemMES.dt_Signal();
// dt_Device = bizFacade.BaseDataSystemMES.dt_Device();
// dt_TagTypeDataType = bizFacade.BaseDataSystemMES.dt_TagTypeDataType();
// //if (LoadOPCData(BasicDataTableFile, IsDemoMesServer, IsWriteMonitorLog, true))
// #region LoadOPCData
// //if (LoadOPCData(dt_Signal, dt_Device, IsDemoMesServer, IsWriteMonitorLog, true))
// //{
// // //MisData_SyncRawData();
// // MesDataFunction.LoadTagTypeCodeID.Load(dt_TagTypeDataType);
// // //MesDataFunction.LoadTagTypeCodeID.Load(BasicDataTableFile);
// // showMessagePLCInvoke = new ShowMessagePLCInvoke(ShowMessagePLC);
// // TestPlcConnectInit();
// // MainFormRefresh = new RefreshForm(button_ReadData_Click);
// // QueryMainFormPosition = new QueryFormData(QueryFormPosition);
// // MainActived = new MainAct(this.Activate);
// // TestPlcStatusDel = new RefreshForm(RefreshPlcConnectStatus);
// // AssemblyManagement.InitAssembly_Recycle();
// // new InitTagValueListData();
// // //设备保养通知计划:设备保养通知计划调度
// // InitMachinePlan(new MachinePlan_Invoke(MachinePlan));
// // if (IsDemoMesServer == 1)
// // {
// // toolStripStatusLabel_RunningStatus.Text = "变量模拟";
// // toolStripStatusLabel_RunningStatus.BackColor = System.Drawing.Color.Yellow;
// // }
// // else
// // {
// // toolStripStatusLabel_RunningStatus.Text = "PLC";
// // toolStripStatusLabel_RunningStatus.BackColor = System.Drawing.Color.Green;
// // }
// // StartTime = Convert.ToDateTime(toolStripStatusLabel_StartTime.Text = DateTime.Now.ToString());
// // Runtime_Thread();
// // //查询出“全部原始基本数据列表”
// // BasicDataTagValue = MesWork.PlcLinkForm.dt_BasicData.Select($"是否启用 = 1 and 变量类型代码=101 or 变量类型代码 = 102 or 变量类型代码 = 105 and 监控属性代码 = '{DataLinkMesWork.ApplicationConfig.MES_Code.ToString()}'").CopyToDataTable<DataRow>();
// // if (BasicDataTagValue.Columns.Contains("上限值"))
// // {
// // BasicDataTagValue.Columns["上限值"].ColumnName = "值上限";
// // }
// // if (BasicDataTagValue.Columns.Contains("下限值"))
// // {
// // BasicDataTagValue.Columns["下限值"].ColumnName = "值下限";
// // }
// // // BasicDataTagValue = MesWork.PlcLinkForm.dt_BasicData.Select($"是否启用 = 1 and 监控属性代码 = '{DataLinkMesWork.ApplicationConfig.MES_Code.ToString()}'").CopyToDataTable<DataRow>();
// // //查询出“MES_基本数据_测量范围”
// // BasicDataTagValueUpDown = MesWork.PlcLinkForm.dt_BasicData;
// // if (BasicDataTagValueUpDown.Columns.Contains("上限值"))
// // {
// // BasicDataTagValueUpDown.Columns["上限值"].ColumnName = "值上限";
// // }
// // if (BasicDataTagValueUpDown.Columns.Contains("下限值"))
// // {
// // BasicDataTagValueUpDown.Columns["下限值"].ColumnName = "值下限";
// // }
// // // 模拟时,写入质量数据
// // //InitBasicDataTagValue();
// // // 变量代码与其他字段的对应关系
// // InitHashtableTagID();
// // this.Cursor = Cursors.Default;
// // Cbx_StatusDisplay_CheckedChanged(null, null);
// // AllowLoad = true;
// // Cbx_StatusDisplay.Enabled = true;
// // button_ReadData_Click(null, null);
// // timer_TestPLC.Enabled = true;
// // EToolStripMenuItem_EquipAlarm_Click(null, null);
// // timer_LoadOver.Enabled = true;
// // TopMost = false;
// // // Thread.Sleep(200);
// // //First_TagMonitor(); //开启发送监控变量第一次的值
// // // Thread.Sleep(200);
// // // Init_TagMonitor(); //开启初始化监控变量
// // Thread.Sleep(200);
// // var deviceState = StartServer(WebApiPort); //开启监控服务
// // loadFinish = true;
// // InitcomboBox_OpNameWebApi();
// // //InitcomboBox_OpName();
// // //初始化程序集列表
// // InitProgramFunctionAssembly();
// // // WorkStationNum_Now = comboBox_OpName.SelectedValue.ToString();
// // ListBox1_Item_Init();
// //}
// #endregion
// //MisData_SyncRawData();
// MesDataFunction.LoadTagTypeCodeID.Load(dt_TagTypeDataType);
// showMessagePLCInvoke = new ShowMessagePLCInvoke(ShowMessagePLC);
// TestPlcConnectInit();
// MainFormRefresh = new RefreshForm(button_ReadData_Click);
// QueryMainFormPosition = new QueryFormData(QueryFormPosition);
// MainActived = new MainAct(this.Activate);
// TestPlcStatusDel = new RefreshForm(RefreshPlcConnectStatus);
// AssemblyManagement.InitAssembly_Recycle();
//// new InitTagValueListData();
// //设备保养通知计划:设备保养通知计划调度
// InitMachinePlan(new MachinePlan_Invoke(MachinePlan));
//if (IsDemoMesServer == 1)
//{
// toolStripStatusLabel_RunningStatus.Text = "变量模拟";
// toolStripStatusLabel_RunningStatus.BackColor = System.Drawing.Color.Yellow;
//}
//else
//{
// toolStripStatusLabel_RunningStatus.Text = "PLC";
// toolStripStatusLabel_RunningStatus.BackColor = System.Drawing.Color.Green;
//}
//StartTime = Convert.ToDateTime(toolStripStatusLabel_StartTime.Text = DateTime.Now.ToString());
//Runtime_Thread();
//// 变量代码与其他字段的对应关系
//InitHashtableTagID();
//this.Cursor = Cursors.Default;
//Cbx_StatusDisplay_CheckedChanged(null, null);
//AllowLoad = true;
//Cbx_StatusDisplay.Enabled = true;
//button_ReadData_Click(null, null);
//timer_TestPLC.Enabled = true;
//EToolStripMenuItem_EquipAlarm_Click(null, null);
//timer_LoadOver.Enabled = true;
//TopMost = false;
//InitcomboBox_OpNameWebApi();
////InitcomboBox_OpName();
////初始化程序集列表
//InitProgramFunctionAssembly();
//// WorkStationNum_Now = comboBox_OpName.SelectedValue.ToString();
//ListBox1_Item_Init();
}
/// <summary>
/// 模拟时,写入质量数据
/// </summary>
private void InitBasicDataTagValue()
{
//if (IsDemoMesServer != 1) return;
//string tagID;
//double tagValue;
////写工位总合格标志 变量类型代码=21
//for (int i = 0; i < MesWork.PlcLinkForm.dt_BasicData.Rows.Count; i++)
//{
// if (MesWork.PlcLinkForm.dt_BasicData.Rows[i]["变量类型代码"].ToString() == "21")
// {
// tagID = MesWork.PlcLinkForm.dt_BasicData.Rows[i]["TagID"].ToString();
// WritePLC(tagID, 1);
// }
//}
//for (int i = 0; i < BasicDataTagValue.Rows.Count; i++)
//{
// try
// {
// switch (Convert.ToInt32(BasicDataTagValue.Rows[i]["变量特点"]))
// {
// case 7:
// tagID = BasicDataTagValue.Rows[i]["TagID"].ToString();
// WritePLC(tagID, 1);
// break;
// case 6:
// tagID = BasicDataTagValue.Rows[i]["TagID"].ToString();
// tagValue = Convert.ToDouble(BasicDataTagValue.Rows[i]["列位置"]) * 100
// + Convert.ToDouble(BasicDataTagValue.Rows[i]["变量排序"]) / 100;
// WritePLC(tagID, tagValue);
// break;
// }
// }
// catch { }
//}
}
/// <summary>
/// 初始化Function对应的程序集
/// </summary>
void InitProgramFunctionAssembly()
{
//int mesServerCode = 0;
//string mesServerdllName = "";
//System.Reflection.Assembly assembly = null;
//foreach (var opName in opNameList)
//{
// try
// {
// mesServerCode = GetMesServerCodeByOpName(opName);
// mesServerdllName = GetMesServeDllByOpName(opName);
// assembly = System.Reflection.Assembly.Load(mesServerdllName);
// if (assembly == null)
// {
// // return;
// }
// if (!MesDataFunction.OpcOperation.Hashtable_assembly.ContainsKey(mesServerdllName))
// {
// MesDataFunction.OpcOperation.Hashtable_assembly.Add(mesServerdllName, assembly);
// }
// }
// catch (Exception err)
// {
// if (!MesDataFunction.OpcOperation.Hashtable_assembly.ContainsKey(mesServerdllName))
// {
// MesDataFunction.OpcOperation.Hashtable_assembly.Add(mesServerdllName, null);
// }
// ApplicationLog.WriteLog(err, err.Message);
// }
//}
}
//List<String> opNameList;
/// <summary>
/// 初始化comboBox_OpName工位号
/// </summary>
private void InitcomboBox_OpName()
{
////全部工位号
//comboBox_OpName.DataSource = opNameList = MesWork.PlcLinkForm.opNameList;
//FunctionForm_HashiTable.OpName_Hash_Write("OpNameList", opNameList);
//toolStripStatusLabel_WorkStationNum.Text = MesWork.PlcLinkForm.opNameList.Count.ToString();
//toolStripStatusLabel_DownLine.Text = toolStripStatusLabel_WorkStationNum.Text;
//WorkStationNum_Now = comboBox_OpName.SelectedValue.ToString();
}
private void InitcomboBox_OpNameWebApi()
{
List<string> opNameList;
//全部工位号
comboBox_OpName.DataSource = opNameList = DtWebApi.OpcDemo.Get_opNameList();
//FunctionForm_HashiTable.OpName_Hash_Write("OpNameList", opNameList);
toolStripStatusLabel_WorkStationNum.Text = opNameList.Count.ToString();
toolStripStatusLabel_DownLine.Text = toolStripStatusLabel_WorkStationNum.Text;
if (comboBox_OpName.Items.Count > 0)
{
WorkStationNum_Now = comboBox_OpName.SelectedValue.ToString();
}
}
private void listBox1_SelectedValueChanged(object sender, EventArgs e)
{
//try
//{
// string cmd;
// string opName;
// string tagValue;
// string[] strList;
// if (listBox1.Text != null)
// {
// strList = listBox1.Text.Split('|');
// if (strList.Length >= 4)
// {
// cmd = strList[1];
// opName = strList[2];
// tagValue = strList[3];
// textBox_Cmd.Text = cmd;
// textBox_tagValue.Text = tagValue;
// }
// }
//}
//catch (Exception err)
//{
// ApplicationLog.WriteLog(err, err.Message);
//}
}
private void button_Write_Click(object sender, EventArgs e)
{
try
{
short tagValue_int;
string tagValue_str;
byte tagValue_byte;
bool tagValue_bool;
int tagType;
int tagDataType;
string cmd = textBox_Cmd.Text;
string opName = WorkStationNum_Now;
string tagValue = textBox_tagValue.Text;
HashtableList htList = DtWebApi.OpcDemo.GetHashtableList();
tagType = Convert.ToInt32(htList.hashtable_TagType[cmd]);
tagDataType = Convert.ToInt32(htList.hashtable_TagTypeDataType[tagType.ToString()]);
switch (tagDataType)
{
case 2:
tagValue_int = Convert.ToInt16(tagValue);
WriteAnyData_Thread(tagType, opName, tagValue_int);
break;
case 8:
tagValue_str = tagValue.ToString();
WriteAnyData_Thread(tagType, opName, tagValue_str);
break;
case 17:
tagValue_byte = Convert.ToByte(tagValue);
WriteAnyData_Thread(tagType, opName, tagValue_byte);
break;
case 11:
tagValue_bool = Convert.ToBoolean(Convert.ToInt32(tagValue));
WriteAnyData_Thread(tagType, opName, tagValue_bool);
break;
}
}
catch (Exception err)
{
MessageBox.Show("输入命令异常,请重新输入!");
//ApplicationLog.WriteLog(err, err.Message);
}
}
private void button_Read_Click(object sender, EventArgs e)
{
try
{
int tagType;
string cmd = textBox_Cmd.Text;
string opName = WorkStationNum_Now;
string tagValue = textBox_tagValue.Text;
HashtableList htList = DtWebApi.OpcDemo.GetHashtableList();
tagType = Convert.ToInt32(htList.hashtable_TagType[cmd]);
QualityDataQueryStruct QualityStruct = new QualityDataQueryStruct(opName, tagType, textBox_tagValue_Read);
Thread t = new Thread(new ParameterizedThreadStart(ReadPLC_ByTagType_Thread));
t.Start(QualityStruct);
}
catch (Exception err)
{
// ApplicationLog.WriteLog(err, err.Message);
}
}
void ReadPLC_ByTagType_Thread(object obj)
{
//try
//{
// QualityDataQueryStruct QualityStruct = (QualityDataQueryStruct)obj;
// TextBox tbx = (TextBox)QualityStruct.Ctrl;
// tbx.Text = ReadPLC(QualityStruct.tagType, QualityStruct.OpName).ToString();
//}
//catch (Exception err)
//{
// ApplicationLog.WriteLog(err, err.Message);
//}
}
bool isWorkStart;
private void timer_WorkStart_Tick(object sender, EventArgs e)
{
//if (isWorkStart)
// isWorkStart = false;
//else
// isWorkStart = true;
//if (isWorkStart)
//{
// textBox_tagValue.Text = "1";
// button_Write_Click(null, null);
//}
//else
//{
// textBox_tagValue.Text = "0";
// button_Write_Click(null, null);
//}
}
private void checkBox_WorkStart_CheckedChanged(object sender, EventArgs e)
{
//if (textBox_Cmd.Text == "" && checkBox_WorkStart.Checked)
//{
// MessageBox.Show("请选择命令");
// checkBox_WorkStart.Checked = false;
// return;
//}
//if (checkBox_WorkStart.Checked)
//{
// timer_WorkStart.Enabled = true;
// listBox1.Enabled = false;
// textBox_Cmd.ReadOnly = true;
//}
//else
//{
// timer_WorkStart.Enabled = false;
// listBox1.Enabled = true;
// textBox_Cmd.ReadOnly = false;
//}
}
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
//timer_WorkStart.Interval = Convert.ToInt32(numericUpDown1.Value) * 1000;
}
static Thread ReadQuality_t = null;
private void ReadQualityData(string opName)
{
try
{
if (ReadQualityRunning) return;
ReadQualityRunning = true;
QualityDataQueryStruct QltyQueryStr = new QualityDataQueryStruct(opName, listView_ShowQualityData);
ReadQuality_t = new Thread(new ParameterizedThreadStart(ReadQualityData_Thread));
ReadQuality_t.Start(QltyQueryStr);
}
catch (Exception err)
{
//ApplicationLog.WriteLog(err, err.Message);
}
}
public QualityDataType[] ThisWorkStationData
{ get; set; }
static bool ReadQualityRunning = false;
void ReadQualityData_Thread(object obj)
{
int fTime = 0;
try
{
QualityDataQueryStruct QualityStruct = (QualityDataQueryStruct)obj;
ListView listViewTemp = (ListView)QualityStruct.Ctrl;
ListViewItem listViewItem = null;
string[] listViewItemString = new string[4];
if (listViewTemp.InvokeRequired)
{
Action ActionDelegate = () => { listViewTemp.Items.Clear(); };
listViewTemp.Invoke(ActionDelegate);
}
else
{
listViewTemp.Items.Clear();
}
System.Collections.Concurrent.ConcurrentDictionary<string, object> cd = new System.Collections.Concurrent.ConcurrentDictionary<string, object>();
List<DoWhatPlc.TagIDTagFormat> cdTagIDTagFormat = null;
if (cb_MonitorData.Checked)
{
cdTagIDTagFormat = DtWebApi.OpcDemo.ReadPLC_GroupMonitor(QualityStruct.OpName);
//cd = MesWork.PlcLinkForm.ReadPLC_GroupMonitor(QualityStruct.OpName);
}
if (cb_QdData.Checked)
{
cdTagIDTagFormat = DtWebApi.OpcDemo.ReadPLC_GroupData_Qd(QualityStruct.OpName);
//cd = MesWork.PlcLinkForm.ReadPLC_GroupData_Qd(QualityStruct.OpName);
}
if (cb_MonitorData.Checked == false & cb_QdData.Checked == false)
{
cdTagIDTagFormat = DtWebApi.OpcDemo.ReadPLC_GroupData(QualityStruct.OpName);
//cd = MesWork.PlcLinkForm.ReadPLC_GroupData(QualityStruct.OpName);
}
if (cb_MonitorData.Checked == true & cb_QdData.Checked == true)
{
cdTagIDTagFormat = DtWebApi.OpcDemo.ReadPLC_GroupData(QualityStruct.OpName);
//cd = MesWork.PlcLinkForm.ReadPLC_GroupData(QualityStruct.OpName);
}
if (cdTagIDTagFormat == null) return;
foreach (var item in cdTagIDTagFormat)
{
if (!cd.ContainsKey(item.TagID))
{
cd.TryAdd(item.TagID, item.TF);
}
}
//排序
var result2 = from pair in cd orderby pair.Key select pair;
ThisWorkStationData = new QualityDataType[cd.Count];
var sortResult2 = from pair in cd orderby pair.Key descending select pair;
//cd.o.OrderBy(p => p.Value.Speed);
//foreach (KeyValuePair<string, object> _cd in cd)
foreach (KeyValuePair<string, object> _cd in result2)
{
var tagID = _cd.Key;
var TF = (DoWhatPlc.TagFormat)_cd.Value;
listViewItemString[0] = TF.OpName;
listViewItemString[3] = TF.TagID;
listViewItemString[1] = TF.ItemName;
listViewItemString[2] = TF.TagValue.ToString();
listViewItem = new ListViewItem(listViewItemString);
if (TF.IsMonitor == 1)
{
listViewItem.BackColor = Color.LimeGreen;
}
if (listViewTemp.InvokeRequired)
{
Action<ListViewItem> ActionDelegate = (x) => { listViewTemp.Items.Add(x); };
listViewTemp.BeginInvoke(ActionDelegate, listViewItem);
}
else
{
listViewTemp.Items.Add(listViewItem);
}
QualityDataType t00 = new QualityDataType();
t00.opName = TF.OpName;
t00.tagID = TF.TagID;
t00.tagTypeID = TF.TagTypeID;
t00.tagValue = TF.TagValue;
ThisWorkStationData[fTime] = t00;
//ThisWorkStationData[fTime].opName = TF.OpName;
//ThisWorkStationData[fTime].tagID = TF.TagID;
//ThisWorkStationData[fTime].tagTypeID = TF.TagTypeID;
//ThisWorkStationData[fTime].tagValue = TF.TagValue;
fTime++;
}
ReadQualityRunning = false;
}
catch (Exception err)
{
ReadQualityRunning = false;
// ApplicationLog.WriteLog(err, err.Message);
}
}
private void button_ReadData_Click(object sender, EventArgs e)
{
ReadQualityData(WorkStationNum_Now);
}
private void comboBox_OpName_SelectedIndexChanged(object sender, EventArgs e)
{
WorkStationNum_Now = comboBox_OpName.SelectedValue.ToString();
}
private void listView_ShowQualityData_MouseDoubleClick(object sender, MouseEventArgs e)
{
try
{
var items = listView_ShowQualityData.SelectedItems;
QualityDataType SelectData = new QualityDataType();
ListView.SelectedIndexCollection index = new ListView.SelectedIndexCollection(listView_ShowQualityData);
SelectData = ThisWorkStationData[index[0]];
WriteQualityValueForm WriteForm = new WriteQualityValueForm(SelectData, this);
WriteForm.ShowDialog();
}
catch (Exception err)
{
//ApplicationLog.WriteLog(err, err.Message);
}
}
private void groupBox_SignialSimulatorBtn_Click(object sender, EventArgs e)
{
WriteBoolSignalByFormBtn(sender);
}
private void Btn_Write_PLC_Click(object sender, EventArgs e)
{
WriteNormalDataBygroupBox_SignialSimulatorWriteBtn(sender);
}
private void Btn_Write_MES_Click(object sender, EventArgs e)
{
WriteNormalDataBygroupBox_SignialSimulatorWriteBtn(sender);
}
private void Btn_Read_PLC_Click(object sender, EventArgs e)
{
ReadPLC_ProductInfo();
}
private void Btn_Read_MES_Click(object sender, EventArgs e)
{
ReadMES_ProductInfo();
}
private void MisData_FormClosed(object sender, FormClosedEventArgs e)
{
//notifyIcon_MIS.Visible = false;
//this.Dispose();
//Application.Exit();
//System.Environment.Exit(0);
}
private void toolStripMenuItem_Show_Click(object sender, EventArgs e)
{
//this.Show();
//this.WindowState = FormWindowState.Normal;
//this.Activate();
}
private void toolStripMenuItem_Hide_Click(object sender, EventArgs e)
{
//this.Hide();
//if (PlcChange != null)
//{
// Sencondform.Invoke(SecondFormClose);
// ToolStripMenuItem_VWSStatus.Checked = false;
//}
}
private void toolStripMenuItem_Exit_Click(object sender, EventArgs e)
{
//this.Close();
}
public static string WorkStationNum_Now;
private void MisData_FormClosing(object sender, FormClosingEventArgs e)
{
//notifyIcon_MIS.Visible = false;
//if (MessageBox.Show("你确定要退出程序吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK)
//{
// notifyIcon_MIS.Visible = false;
// e.Cancel = false;
// //判断SecondForm是否关闭
// if (PlcChange != null)
// {
// Sencondform.BeginInvoke(SecondFormClose);
// }
// StopServer();
// MesWork.Mqtt.StopAsync();
//}
//else
//{
// notifyIcon_MIS.Visible = true;
// e.Cancel = true;
//}
}
private void ToolStripMenuItem_PrintScreen_Click(object sender, EventArgs e)
{
//PrintMainForm_Thread();
}
private void ToolStripMenuItem_Quit_Click(object sender, EventArgs e)
{
//this.Close();
}
private void ToolStripMenuItem_SaveLog_Click(object sender, EventArgs e)
{
//SavePLCMessage SavePlcMSG = new SavePLCMessage();
//SavePlcMSG.SavePlcMessage_Thread(richTextBox_MessagePLC.Text);
}
private void ToolStripMenuItem_LockForm_Click(object sender, EventArgs e)
{
//MainFormLock = new MainAct(LockMainForm);
//MainFormUnlock = new MainAct(UnLockForm);
//MainLockConfirm LockConfirm = new MainLockConfirm(this, Sencondform);
//LockConfirm.ShowDialog();
}
private void ToolStripMenuItem_VWSStatus_Click(object sender, EventArgs e)
{
//if (PlcChange == null)
//{
// OpenSecondForm_Thread();
//}
//else
//{
// Sencondform.BeginInvoke(SecondFormClose);
// ToolStripMenuItem_VWSStatus.Checked = false;
//}
}
private void MToolStripMenuItem_AboutMacroinf_Click(object sender, EventArgs e)
{
//System.Diagnostics.Process.Start("https://www.meswork.com");
}
private void toolStripMenuItem_HVersion_Click(object sender, EventArgs e)
{
//VersionsInformation VersionForm = new VersionsInformation();
//VersionForm.ShowDialog();
}
private void MisData_Load(object sender, EventArgs e)
{
//MesWork.Mqtt.StartAsync(MqttUrl);
//MesWork.Mqtt.mqttClient.ConnectedHandler = new MqttClientConnectedHandlerDelegate(OnSubscriberConnected);
//MesWork.Mqtt.mqttClient.DisconnectedHandler = new MqttClientDisconnectedHandlerDelegate(OnSubscriberDisconnected);
//MesWork.Mqtt.mqttClient.ApplicationMessageReceivedHandler = new MqttApplicationMessageReceivedHandlerDelegate(OnSubscriberMessageReceived);
}
bool EToolStripMenuItem_EquipAlarm_Visiable = false;
private void ToolStripMenuItem_HHelp_Click(object sender, EventArgs e)
{
//string file = Environment.CurrentDirectory + "\\MisData操作手册.pdf";
//string str = file.Replace("\\bin\\Debug", "\\PDF\\MisData说明文档.pdf");
//System.Diagnostics.Process.Start(file);
}
/// <summary>
/// 程序集界面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ToolStripMenuItem_Assembly_Click(object sender, EventArgs e)
{
//AssemblyManagement AssemblyView = new AssemblyManagement();
//AssemblyView.ShowDialog();
}
//MesWork.OpcForm opcForm = null;
private void TSM_DebugPage_Click(object sender, EventArgs e)
{
//if (opcForm != null)
//{
// opcForm.Close();
// opcForm.Dispose();
// opcForm = null;
//}
//opcForm = new MesWork.OpcForm(IsDemoMesServer);
//opcForm.Show();
}
private void button1_Click(object sender, EventArgs e)
{
//WritePLC("71015001", 1);
//WritePLC("71015002", 1.1);
//WritePLC("71015003", 2.2);
//WritePLC("71015004", 0);
//WritePLC("71015005", 3.3);
//WritePLC("71015006", 4.4);
}
private void label_OpNameList_DoubleClick(object sender, EventArgs e)
{
InitcomboBox_OpNameWebApi();
}
private void EToolStripMenuItem_EquipAlarm_Click(object sender, EventArgs e)
{
//try
//{
// if (!EToolStripMenuItem_EquipAlarm.Checked)
// {
// groupBox_WorkStationQuality.Width = 307;
// groupBox_WorkStationQuality.Height = 313;
// listView_ShowQualityData.Width = 294;
// listView_ShowQualityData.Height = 234;
// button_ReadData_Click(null, null);
// groupBox_Alarm.Visible = true;
// EToolStripMenuItem_EquipAlarm.Checked = true;
// EToolStripMenuItem_EquipAlarm_Visiable = true;
// }
// else
// {
// groupBox_Alarm.Visible = false;
// groupBox_WorkStationQuality.Width = 307;
// groupBox_WorkStationQuality.Height = 642;
// listView_ShowQualityData.Width = 294;
// listView_ShowQualityData.Height = 572;
// button_ReadData_Click(null, null);
// EToolStripMenuItem_EquipAlarm.Checked = false;
// }
//}
//catch (Exception err)
//{
// ApplicationLog.WriteLog(err, err.Message);
//}
}
}
}

209
Test/MisDataWebFun.resx Normal file
View File

@@ -0,0 +1,209 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="contextMenuStrip_MIS.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>423, 5</value>
</metadata>
<metadata name="menuStrip_Main.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>608, 4</value>
</metadata>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>749, 3</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>37</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAEAICAAAAEAIACoEAAAFgAAACgAAAAgAAAAQAAAAAEAIAAAAAAAABAAABMLAAATCwAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMgChADIAoQIyAKEgMgChczIA
occyAKHqMgChmTIAoTwyAKEJMgChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMgChADIAoQQyAKEvMgChdzIA
odYyAKH7MgCh/zIAof8yAKH/MgCh6jIAoacyAKFJMgChEjIAoQAyAKEAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAyAKEAMgChADIAoQoyAKE+MgChkTIA
oeoyAKH+MgCh+TIAoe0yAKH+MgCh/zIAofwyAKH3MgCh/jIAofgyAKHBMgChZDIAoR4yAKEBMgChAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAyAKEAMgChATIAoRUyAKFcMgChujIA
ofEyAKH/MgCh9DIAobc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AAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAADIAoQAyAKECMgChFTIAoVcyAKGaMgCh3DIAodEyAKGaMgChSDIAoQsyAKEAMgChATIA
oSUyAKGGMgCh6TIAofEyAKHhMgChtzIAoXAyAKErMgChBTIAoQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMgChADIAoQIyAKElMgChXTIAobgyAKHbMgChxTIA
oYUyAKFbMgChqzIAodEyAKHLMgChhDIAoTsyAKELMgChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAyAKEAMgChCzIA
oTcyAKGTMgCh0zIAofAyAKG2MgChWjIAoRcyAKEBMgChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAA/+Af//+AB//8AAD/8AAAP8AIAA8AGDABARg+AQEYD4ERGAPxMZgAcTOY
ADEzmDAxM5g8MTKIPzEgCDDxIAgwMSB4MAEgeDgBJHg+ATxAD8E8AAHxOAAAMQAAAAEAAwABABwgAQBE
BAEBwAABAEAAA+AAAA/4AAB//wAD///gD/8=
</value>
</data>
</root>

View File

@@ -0,0 +1,107 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
//using SystemFramework;
namespace MisDataSaveDate
{
public partial class MisData
{
void ReadPLC_ProductInfo()
{
try
{
foreach (Control Tbx in this.groupBox_PLC.Controls)
{
Thread t = new Thread(new ParameterizedThreadStart(ReadPLC_ProductInfo_Thread));
t.Start(Tbx);
}
}
catch (Exception err)
{
//ApplicationLog.WriteLog(err, err.Message);
}
}
void ReadPLC_ProductInfo_Thread(object obj)
{
try
{
Control Tbx = (Control)obj;
if (Tbx.Name.Length < 12) return;
if (Tbx.Name.Substring(0, 8) != "Tbx_PLC_") return;
string[] TbxName_Split = Tbx.Name.Split('_');
int TagType = Convert.ToInt32(TbxName_Split[2]);
if (Tbx.InvokeRequired )
{
Action<string> actionDelegate = (x) => { Tbx.Text = x; };
Tbx.BeginInvoke(actionDelegate, DtWebApi.ReadWritePLC.ReadPLC(TagType.ToString(), WorkStationNum_Now).ToString());
}
else
{
Tbx.Text = DtWebApi.ReadWritePLC.ReadPLC(TagType.ToString(), WorkStationNum_Now).ToString();
}
}
catch (Exception err)
{
//ApplicationLog.WriteLog(err, err.Message);
}
}
void ReadMES_ProductInfo()
{
try
{
foreach (Control Tbx in this.groupBox_MES.Controls)
{
Thread t = new Thread(new ParameterizedThreadStart(ReadMES_ProductInfo_Thread));
t.Start(Tbx);
}
}
catch (Exception err)
{
//ApplicationLog.WriteLog(err, err.Message);
}
}
void ReadMES_ProductInfo_Thread(object obj)
{
try
{
Control Tbx = (Control)obj;
if (Tbx.Name.Length < 12) return;
if (Tbx.Name.Substring(0, 8) != "Tbx_MES_") return;
string[] TbxName_Split = Tbx.Name.Split('_');
int TagType = Convert.ToInt32(TbxName_Split[2]);
if (Tbx .InvokeRequired )
{
Action<string> ActionDelegate = (x) => { Tbx.Text = x; };
Tbx.BeginInvoke(ActionDelegate, DtWebApi.ReadWritePLC.ReadPLC(TagType.ToString(), WorkStationNum_Now).ToString());
}
else
{
Tbx.Text = DtWebApi.ReadWritePLC.ReadPLC(TagType.ToString(), WorkStationNum_Now).ToString();
}
}
catch (Exception err)
{
//ApplicationLog.WriteLog(err, err.Message);
}
}
}
}

114
Test/WriteQualityValueForm.Designer.cs generated Normal file
View File

@@ -0,0 +1,114 @@
namespace MisDataSaveDate
{
partial class WriteQualityValueForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label_Message = new System.Windows.Forms.Label();
this.textBox_InputValue = new System.Windows.Forms.TextBox();
this.button_OK = new System.Windows.Forms.Button();
this.button_Cancle = new System.Windows.Forms.Button();
this.comboBox_InputValue = new System.Windows.Forms.ComboBox();
this.SuspendLayout();
//
// label_Message
//
this.label_Message.AutoSize = true;
this.label_Message.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label_Message.Location = new System.Drawing.Point(15, 10);
this.label_Message.Name = "label_Message";
this.label_Message.Size = new System.Drawing.Size(41, 12);
this.label_Message.TabIndex = 0;
this.label_Message.Text = "label1";
//
// textBox_InputValue
//
this.textBox_InputValue.Location = new System.Drawing.Point(10, 50);
this.textBox_InputValue.Name = "textBox_InputValue";
this.textBox_InputValue.Size = new System.Drawing.Size(475, 21);
this.textBox_InputValue.TabIndex = 1;
//
// button_OK
//
this.button_OK.Location = new System.Drawing.Point(268, 81);
this.button_OK.Name = "button_OK";
this.button_OK.Size = new System.Drawing.Size(95, 25);
this.button_OK.TabIndex = 2;
this.button_OK.Text = "OK";
this.button_OK.UseVisualStyleBackColor = true;
this.button_OK.Click += new System.EventHandler(this.button_OK_Click);
//
// button_Cancle
//
this.button_Cancle.Location = new System.Drawing.Point(369, 81);
this.button_Cancle.Name = "button_Cancle";
this.button_Cancle.Size = new System.Drawing.Size(95, 25);
this.button_Cancle.TabIndex = 2;
this.button_Cancle.Text = "Cancel";
this.button_Cancle.UseVisualStyleBackColor = true;
this.button_Cancle.Click += new System.EventHandler(this.button_Cancle_Click);
//
// comboBox_InputValue
//
this.comboBox_InputValue.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBox_InputValue.FormattingEnabled = true;
this.comboBox_InputValue.Items.AddRange(new object[] {
"false",
"true"});
this.comboBox_InputValue.Location = new System.Drawing.Point(10, 50);
this.comboBox_InputValue.Name = "comboBox_InputValue";
this.comboBox_InputValue.Size = new System.Drawing.Size(475, 20);
this.comboBox_InputValue.TabIndex = 3;
//
// WriteQualityValueForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(494, 111);
this.Controls.Add(this.comboBox_InputValue);
this.Controls.Add(this.button_Cancle);
this.Controls.Add(this.button_OK);
this.Controls.Add(this.textBox_InputValue);
this.Controls.Add(this.label_Message);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "WriteQualityValueForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Write value";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label_Message;
private System.Windows.Forms.TextBox textBox_InputValue;
private System.Windows.Forms.Button button_OK;
private System.Windows.Forms.Button button_Cancle;
private System.Windows.Forms.ComboBox comboBox_InputValue;
}
}

View File

@@ -0,0 +1,266 @@
using System;
using System.Windows.Forms;
//using BasicData;
using System.Text.RegularExpressions;
//using SystemFramework;
using System.Threading;
using DoWhatPlc;
namespace MisDataSaveDate
{
public partial class WriteQualityValueForm : Form
{
QualityDataType SelectListData;
Form MainForm;
public WriteQualityValueForm(QualityDataType SelectData,Form Mainform)
{
try
{
InitializeComponent();
SelectListData = new QualityDataType();
SelectListData = SelectData;
SetForm(SelectData.tagTypeID, SelectData.tagValue);
MainForm = Mainform;
}
catch (Exception err)
{
//ApplicationLog.WriteLog(err, err.Message);
}
}
private void button_OK_Click(object sender, EventArgs e)
{
try
{
if (!TagTypeID_Confirm(SelectListData.tagTypeID)) return;
this.Hide () ;
QualityDataQueryStruct QualityStruct = new QualityDataQueryStruct(SelectListData.tagID , SelectListData.tagTypeID , comboBox_InputValue.SelectedIndex.ToString(), textBox_InputValue.Text,this);
Thread t = new Thread(new ParameterizedThreadStart(WriteQualityDataByTagID_Thread));
t.Start(QualityStruct);
}
catch (Exception err)
{
//ApplicationLog.WriteLog(err, err.Message);
}
}
void WriteQualityDataByTagID_Thread(object obj)
{
try
{
QualityDataQueryStruct QualityStruct = (QualityDataQueryStruct)obj;
Form ThisForm = (Form)QualityStruct.tempForm;
if (QualityStruct.tagTypeID == 11)
{
DtWebApi.ReadWritePLC.WritePLC(QualityStruct.tagID, QualityStruct.tagValue.ToString());
}
else
{
DtWebApi.ReadWritePLC.WritePLC(SelectListData.tagID, QualityStruct.tagValue2.ToString());
}
MainForm.BeginInvoke (MisData.MainFormRefresh, null, null);
Action ActionDelete = () => { this.Close();this.Dispose(); };
if(this.InvokeRequired )
{
ThisForm.BeginInvoke(ActionDelete);
}
else
{
ActionDelete();
}
}
catch (Exception err)
{
//ApplicationLog.WriteLog(err, err.Message);
}
}
private void button_Cancle_Click(object sender, EventArgs e)
{
this.Close();
this.Dispose();
}
void SetForm( int TagTypeID,object TagValue)
{
try
{
switch (TagTypeID)
{
case 11://BOOL
comboBox_InputValue.Enabled = true;
comboBox_InputValue.Visible = true;
textBox_InputValue.Enabled = false;
textBox_InputValue.Visible = false;
label_Message.Text = "Data type: Boolean";
if (Convert.ToBoolean(TagValue))
{
comboBox_InputValue.SelectedIndex = 1;
}
else
{
comboBox_InputValue.SelectedIndex = 0;
}
break;
case 2://INT.
label_Message.Text = "Data type: Int16 Range from -32768 to 32767";
comboBox_InputValue.Enabled = false;
comboBox_InputValue.Visible = false;
textBox_InputValue.Enabled = true;
textBox_InputValue.Visible = true;
textBox_InputValue.Text = TagValue.ToString();
break;
case 17://BYTE
label_Message.Text = "Data type: Byte Range from 0 to 255";
comboBox_InputValue.Enabled = false;
comboBox_InputValue.Visible = false;
textBox_InputValue.Enabled = true;
textBox_InputValue.Visible = true;
textBox_InputValue.Text = TagValue.ToString();
break;
case 8://STRING
label_Message.Text = "Data type: String";
comboBox_InputValue.Enabled = false;
comboBox_InputValue.Visible = false;
textBox_InputValue.Enabled = true;
textBox_InputValue.Visible = true;
textBox_InputValue.Text = TagValue.ToString();
break;
case 18://Word
label_Message.Text = "Data type: UInt16 Range from 0 to 65535";
comboBox_InputValue.Enabled = false;
comboBox_InputValue.Visible = false;
textBox_InputValue.Enabled = true;
textBox_InputValue.Visible = true;
textBox_InputValue.Text = TagValue.ToString();
break;
case 4://real
label_Message.Text = "Data type: Single Range from -3.402823E+38 to 3.402823E+38";
comboBox_InputValue.Enabled = false;
comboBox_InputValue.Visible = false;
textBox_InputValue.Enabled = true;
textBox_InputValue.Visible = true;
textBox_InputValue.Text = TagValue.ToString();
break;
default://Unknow
label_Message.Text = "Data type: Unknow";
comboBox_InputValue.Enabled = false;
comboBox_InputValue.Visible = false;
textBox_InputValue.Enabled = true;
textBox_InputValue.Visible = true;
textBox_InputValue.Text = TagValue.ToString();
break;
}
}
catch (Exception err)
{
//ApplicationLog.WriteLog(err, err.Message);
}
}
bool TagTypeID_Confirm( int TagTypeID)
{
try
{
switch (TagTypeID)
{
case 2://INT
//TextBox存在非数字字符 报错
if (!Regex.IsMatch(textBox_InputValue.Text, @"^[-]?\d*$"))
{
MessageBox.Show("输入不是整数!");
return false;
}
if (textBox_InputValue.Text.Length > 9)
{
MessageBox.Show("输入数据不在范围内");
return false;
}
break;
case 17://BYTE
//TextBox存在非数字字符 报错
if (!Regex.IsMatch(textBox_InputValue.Text, @"^[-]?\d*$"))
{
MessageBox.Show("输入不是整数!");
return false;
}
if (Convert.ToInt32(textBox_InputValue.Text.Trim()) > 255)
{
MessageBox.Show("输入数据不在范围内");
return false;
}
break;
case 8://STRING
break;
case 18://Word
//TextBox存在非数字字符 报错
if (!Regex.IsMatch(textBox_InputValue.Text, @"^[-]?\d*$"))
{
MessageBox.Show("输入不是整数!");
return false;
}
if (textBox_InputValue.Text.Trim().Length > 4)
{
MessageBox.Show("输入数据不在范围内");
return false;
}
break;
case 4://real
//TextBox存在非数字字符 报错
//TextBox存在非数字字符 报错
if (!Regex.IsMatch(textBox_InputValue.Text, @"^-?\d+\.?\d*$"))
{
MessageBox.Show("输入不是实数!");
return false;
}
break;
default:
break;
}
return true;
}
catch (Exception err)
{
//ApplicationLog.WriteLog(err, err.Message);
return true;
}
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>