init: 导入项目到 meswork Gitea
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace MisDataName
|
||||
{
|
||||
public struct ControlData
|
||||
{
|
||||
public ControlData(Control Ctrl, string OpName)
|
||||
{
|
||||
string[] Array_NameSplit;
|
||||
Array_NameSplit = Ctrl.Name.Split('_');
|
||||
TagType = Convert.ToInt32(Array_NameSplit[2]);
|
||||
opName = OpName;
|
||||
btn = Ctrl;
|
||||
|
||||
}
|
||||
|
||||
public int TagType;
|
||||
public string opName;
|
||||
public Control btn;
|
||||
|
||||
|
||||
}
|
||||
public struct ControlChangeByTagType
|
||||
{
|
||||
public ControlChangeByTagType(int tagType, string value)
|
||||
{
|
||||
TagType = tagType;
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public int TagType;
|
||||
public string Value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using SystemFramework;
|
||||
|
||||
namespace MisDataName
|
||||
{
|
||||
public partial class MisData
|
||||
{
|
||||
void OpenSecondForm_Thread()
|
||||
{
|
||||
try
|
||||
{
|
||||
ToolStripMenuItem_VWSStatus.Checked = true;
|
||||
|
||||
Thread t = new Thread(new ParameterizedThreadStart(OpenSecondForm));
|
||||
t.Start(this);
|
||||
SecondForm.MainMenuRefresh = new MisDataName.SecondAct(RefreshToolStripMenuItem_Checked_ByName);
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, err.Message );
|
||||
}
|
||||
}
|
||||
|
||||
Form Sencondform;
|
||||
void OpenSecondForm( object ThisForm)
|
||||
{
|
||||
try
|
||||
{
|
||||
SecondForm f1 = new SecondForm( ThisForm);
|
||||
Sencondform = f1;
|
||||
f1.ShowDialog();
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, err.Message );
|
||||
}
|
||||
}
|
||||
|
||||
void RefreshToolStripMenuItem_Checked_ByName(string ControlName)
|
||||
{
|
||||
try
|
||||
{
|
||||
ToolStripItem[] tsItems = menuStrip_Main.Items.Find(ControlName, true);
|
||||
ToolStripMenuItem tsmItem = (ToolStripMenuItem)tsItems[0];
|
||||
if (PlcChange == null)
|
||||
{
|
||||
tsmItem.Checked = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
tsmItem.Checked = true;
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, err.Message );
|
||||
}
|
||||
}
|
||||
|
||||
object QueryFormPosition(object obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new Point(this.Left + this.Width, this.Top);
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, err.Message);
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,515 @@
|
||||
using BasicData;
|
||||
|
||||
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 MisDataName
|
||||
{
|
||||
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 = ReadPLC(Btn.TagType, 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 = "";
|
||||
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)
|
||||
{
|
||||
Write_TagTypeID(QDQ.tagType, QDQ.OpName, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
Write_TagTypeID(QDQ.tagType, QDQ.OpName, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool ReadResult = Convert.ToBoolean(MesDataFunction.OpcOperation.ReadPLC(QDQ.tagType, QDQ.OpName));
|
||||
if (ReadResult)
|
||||
{
|
||||
MesDataFunction.OpcOperation.WritePLC(QDQ.tagType, QDQ.OpName, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
MesDataFunction.OpcOperation.WritePLC(QDQ.tagType, 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]);
|
||||
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;
|
||||
}
|
||||
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]);
|
||||
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;
|
||||
|
||||
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 = MisDataFunction.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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using SystemFramework;
|
||||
|
||||
namespace MisDataName
|
||||
{
|
||||
partial class MisData
|
||||
{
|
||||
|
||||
void TestPlcConnectInit()
|
||||
{
|
||||
//try
|
||||
//{
|
||||
// DataTable dt_OpName = (DataTable)FunctionForm_HashiTable.OpName_Hash_Read("OpNameList");
|
||||
// for (int i=0;i< dt_OpName.Rows .Count;i++)
|
||||
// {
|
||||
// TestPlcConnect NewPlcConnect = new TestPlcConnect(dt_OpName.Rows [i][0].ToString ());
|
||||
// TestPlcConnect.TestPlcTimerChangedDelegate += NewPlcConnect.ExternalTimerExcute;
|
||||
// NewPlcConnect.PlcConnect += PlcStatusChanged_Connect;
|
||||
// NewPlcConnect.PlcBreak += PlcStatusChanged_Break;
|
||||
// TestPlcConnect.HashTable_Write(TestPlcConnect.WorkStationTestExample, dt_OpName.Rows[i][0].ToString(), NewPlcConnect);
|
||||
|
||||
// }
|
||||
//}
|
||||
//catch (Exception err)
|
||||
//{
|
||||
// ApplicationLog.WriteLog(err, err.Message);
|
||||
|
||||
//}
|
||||
}
|
||||
|
||||
public static void PlcStatusChanged_Connect(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
//查询在线工位数量
|
||||
int i= TestPlcConnect. CalculateWorkStationCount("OnlineWorkStation");
|
||||
|
||||
if (MisData.TestPlcStatusDel!=null )
|
||||
MisData.TestPlcStatusDel(i.ToString (), e);
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, err.Message);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void PlcStatusChanged_Break(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
//查询在线工位数量
|
||||
int i = TestPlcConnect.CalculateWorkStationCount("OnlineWorkStation");
|
||||
|
||||
if (MisData.TestPlcStatusDel != null)
|
||||
MisData.TestPlcStatusDel(i.ToString(), e);
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, err.Message);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ListBox1_Item_Init()
|
||||
{
|
||||
listBox1.Items.Clear();
|
||||
|
||||
foreach (var i in MesDataFunction.OpcOperation.hashtable_TagType)
|
||||
{
|
||||
listBox1.Items.Add("MES|" + i.ToString() + "|"+ WorkStationNum_Now + "|1");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace MisDataName
|
||||
{
|
||||
public struct QualityDataQueryStruct
|
||||
{
|
||||
|
||||
public QualityDataQueryStruct(string opName, Control ctrl)
|
||||
{
|
||||
OpName = opName;
|
||||
Ctrl = ctrl;
|
||||
tagType = 0;
|
||||
tagValue = "";
|
||||
tagID = "";
|
||||
tagTypeID = 0;
|
||||
tempForm = null;
|
||||
tagValue2 = null;
|
||||
|
||||
}
|
||||
|
||||
public QualityDataQueryStruct(string opName,int TagType)
|
||||
{
|
||||
|
||||
OpName = opName;
|
||||
Ctrl = null;
|
||||
tagType = TagType;
|
||||
tagValue = "";
|
||||
tagID = "";
|
||||
tagTypeID = 0;
|
||||
tempForm = null;
|
||||
tagValue2 = null;
|
||||
}
|
||||
|
||||
public QualityDataQueryStruct(string opName, int TagType, Control ctrl)
|
||||
{
|
||||
|
||||
OpName = opName;
|
||||
Ctrl = ctrl;
|
||||
tagType = TagType;
|
||||
tagValue = "";
|
||||
tagID = "";
|
||||
tagTypeID = 0;
|
||||
tempForm = null;
|
||||
tagValue2 = null;
|
||||
}
|
||||
public QualityDataQueryStruct(string opName, int TagType,object TagValue)
|
||||
{
|
||||
|
||||
OpName = opName;
|
||||
Ctrl = null;
|
||||
tagType = TagType;
|
||||
tagValue = TagValue;
|
||||
tagID = "";
|
||||
tagTypeID = 0;
|
||||
tempForm = null;
|
||||
tagValue2 = null;
|
||||
}
|
||||
public QualityDataQueryStruct(string TagID,int TagTypeID , object TagValue, object TagValue2, Form TempForm)
|
||||
{
|
||||
|
||||
OpName = "" ;
|
||||
Ctrl = null;
|
||||
tagType = 0;
|
||||
tagValue = TagValue;
|
||||
tagID = TagID;
|
||||
tagTypeID = TagTypeID;
|
||||
tempForm = TempForm;
|
||||
tagValue2 = TagValue2;
|
||||
}
|
||||
|
||||
|
||||
public string OpName;
|
||||
public Control Ctrl;
|
||||
public int tagType;
|
||||
public object tagValue;
|
||||
public object tagValue2;
|
||||
public string tagID;
|
||||
public int tagTypeID;
|
||||
public Form tempForm;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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 MisDataName
|
||||
{
|
||||
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, ReadPLC(TagType, WorkStationNum_Now).ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
Tbx.Text = ReadPLC(TagType, 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, ReadPLC(TagType, WorkStationNum_Now).ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
Tbx.Text = ReadPLC(TagType, WorkStationNum_Now).ToString();
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, err.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace MisDataName
|
||||
{
|
||||
public delegate void TestPlcDelegate();
|
||||
public class TestPlcConnect
|
||||
{
|
||||
public static Hashtable WorkStationStatus_Hash = new Hashtable();
|
||||
public static Hashtable WorkStationTestExample = new Hashtable();
|
||||
|
||||
string WorkStationStr = "";
|
||||
|
||||
public EventHandler PlcBreak,PlcConnect;
|
||||
|
||||
bool PlcStatus=false ;
|
||||
|
||||
static int testTime = 10;
|
||||
int TestInterval = testTime;
|
||||
|
||||
string OpName;
|
||||
|
||||
|
||||
public TestPlcConnect(string opName)
|
||||
{
|
||||
OpName = opName;
|
||||
}
|
||||
|
||||
public void ExternalSignalChange()
|
||||
{
|
||||
TestInterval = testTime;
|
||||
if(!PlcStatus)
|
||||
{
|
||||
|
||||
WorkStationStr=ReadWorkStationStr("OnlineWorkStation");
|
||||
HashTable_Write(WorkStationStatus_Hash,"OnlineWorkStation", String_Combine(WorkStationStr, OpName));
|
||||
WorkStationStr = ReadWorkStationStr("DownlineWorkStation");
|
||||
HashTable_Write(WorkStationStatus_Hash, "DownlineWorkStation", String_Spl(WorkStationStr, OpName));
|
||||
|
||||
if (PlcConnect != null)
|
||||
{
|
||||
PlcConnect(OpName, null);
|
||||
}
|
||||
|
||||
|
||||
PlcStatus = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void ExternalTimerExcute()
|
||||
{
|
||||
if (TestInterval>0)
|
||||
{
|
||||
TestInterval--;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if(PlcStatus)
|
||||
{
|
||||
|
||||
WorkStationStr = ReadWorkStationStr("DownlineWorkStation");
|
||||
HashTable_Write(WorkStationStatus_Hash, "DownlineWorkStation", String_Combine(WorkStationStr, OpName));
|
||||
WorkStationStr = ReadWorkStationStr("OnlineWorkStation");
|
||||
HashTable_Write(WorkStationStatus_Hash, "OnlineWorkStation", String_Spl(WorkStationStr, OpName));
|
||||
|
||||
if (PlcBreak != null)
|
||||
{
|
||||
PlcBreak(OpName, null);
|
||||
}
|
||||
|
||||
PlcStatus = false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void HashTable_Write(Hashtable hashtable, string Key,object obj)
|
||||
{
|
||||
if (hashtable.ContainsKey (Key))
|
||||
{
|
||||
hashtable[Key] = obj;
|
||||
}
|
||||
else
|
||||
{
|
||||
hashtable.Add(Key, obj);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static object HashTable_Read(Hashtable hashtable, string Key)
|
||||
{
|
||||
if (hashtable.ContainsKey(Key))
|
||||
{
|
||||
return hashtable[Key];
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
string ReadWorkStationStr(string Key)
|
||||
{
|
||||
if ( HashTable_Read(WorkStationStatus_Hash, Key) !=null )
|
||||
{
|
||||
return HashTable_Read(WorkStationStatus_Hash, Key).ToString();
|
||||
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
string String_Combine(string MainStr,string AddStr)
|
||||
{
|
||||
return MainStr+ AddStr + "|";
|
||||
|
||||
}
|
||||
string String_Spl(string MainStr, string DelStr)
|
||||
{
|
||||
return MainStr.Replace(DelStr + "|", "");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static int CalculateWorkStationCount(string Key)
|
||||
{
|
||||
string wksta="";
|
||||
if(WorkStationStatus_Hash.ContainsKey (Key))
|
||||
{
|
||||
wksta = WorkStationStatus_Hash[Key].ToString();
|
||||
}
|
||||
string[] wksta_SplitArray = wksta.Split('|');
|
||||
|
||||
return wksta_SplitArray.Length-1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static void HeartBeatChange(string OpName, int TagTypeID)
|
||||
{
|
||||
if (TagTypeID == 14)
|
||||
{
|
||||
Thread t = new Thread(new ParameterizedThreadStart(HeartBeatChange_Thread));
|
||||
t.Start(OpName);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
static void HeartBeatChange_Thread(object obj)
|
||||
{
|
||||
string OpName = (string)obj;
|
||||
if (TestPlcConnect.HashTable_Read(TestPlcConnect.WorkStationTestExample, OpName) != null)
|
||||
{
|
||||
TestPlcConnect PlcConnectExample = (TestPlcConnect)TestPlcConnect.HashTable_Read(TestPlcConnect.WorkStationTestExample, OpName);
|
||||
PlcConnectExample.ExternalSignalChange();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using SystemFramework;
|
||||
using System.Threading;
|
||||
|
||||
namespace MisDataName
|
||||
{
|
||||
public partial class MisData
|
||||
{
|
||||
|
||||
void initStationStatus()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!Cbx_StatusDisplay.Checked) return;
|
||||
foreach (Control Tbx in this.groupBox_WorkStationStatus.Controls)
|
||||
{
|
||||
Thread t = new Thread(new ParameterizedThreadStart(initStationStatus_Thread));
|
||||
t.Start(Tbx);
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, err.Message);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void initStationStatus_Thread(object obj )
|
||||
{
|
||||
try
|
||||
{
|
||||
Control Tbx = (Control)obj;
|
||||
if (Tbx.Name.Length < 12) return ;
|
||||
if (Tbx.Name.Substring(0, 11) == "Tbx_Status_")
|
||||
{
|
||||
string[] TbxNameSplitArray = Tbx.Name.Split('_');
|
||||
int Tagtype = Convert.ToInt32(TbxNameSplitArray[2]);
|
||||
if (Tbx .InvokeRequired )
|
||||
{
|
||||
Action<string> ActionDelegate = (x) => { Tbx.Text = x; };
|
||||
Tbx.BeginInvoke(ActionDelegate, MesDataFunction.OpcOperation.ReadPLC(Tagtype, WorkStationNum_Now).ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
Tbx.Text = MesDataFunction.OpcOperation.ReadPLC(Tagtype, WorkStationNum_Now).ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, err.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RefreshStationStatus(object obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
ControlChangeByTagType ControlValue = (ControlChangeByTagType)obj;
|
||||
|
||||
if (!Cbx_StatusDisplay.Checked) return;
|
||||
foreach (Control Tbx in this.groupBox_WorkStationStatus.Controls)
|
||||
{
|
||||
if (Tbx.Name.Length < 12) continue;
|
||||
if (Tbx.Name.Substring(0, 11) == "Tbx_Status_")
|
||||
{
|
||||
string[] TbxNameSplitArray = Tbx.Name.Split('_');
|
||||
int Tagtype = Convert.ToInt32(TbxNameSplitArray[2]);
|
||||
if (ControlValue.TagType == Tagtype)
|
||||
{
|
||||
if (Tbx.InvokeRequired)
|
||||
{
|
||||
Action<string> ActionDelegate = (x) => { Tbx.Text = x; };
|
||||
Tbx.BeginInvoke(ActionDelegate, ControlValue.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
Tbx.Text = ControlValue.Value;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, err.Message);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
void RefreshStationStatus_Thread(int TargetTagtype, string TbxText)
|
||||
{
|
||||
ControlChangeByTagType ControlValue = new MisDataName.ControlChangeByTagType(TargetTagtype, TbxText);
|
||||
Thread t = new Thread(new ParameterizedThreadStart(RefreshStationStatus));
|
||||
t.Start(ControlValue);
|
||||
}
|
||||
|
||||
void RefreshStationStatusWriteNull()
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (Control Tbx in this.groupBox_WorkStationStatus.Controls)
|
||||
{
|
||||
if (Tbx.Name.Length < 12) continue;
|
||||
if (Tbx.Name.Substring(0, 11) == "Tbx_Status_")
|
||||
{
|
||||
Tbx.Text = "未开启同步";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ApplicationLog.WriteLog(err, err.Message);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
114
MisData_3.0_2022.08.23.1622.LLX/MisData/MisAddition/WriteQualityValueForm.Designer.cs
generated
Normal file
114
MisData_3.0_2022.08.23.1622.LLX/MisData/MisAddition/WriteQualityValueForm.Designer.cs
generated
Normal file
@@ -0,0 +1,114 @@
|
||||
namespace MisDataName
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,265 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using BasicData;
|
||||
using System.Text.RegularExpressions;
|
||||
using SystemFramework;
|
||||
using System.Threading;
|
||||
|
||||
namespace MisDataName
|
||||
{
|
||||
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)
|
||||
{
|
||||
MisData.WritePLC(QualityStruct.tagID, QualityStruct.tagValue.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
MisData.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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
BIN
MisData_3.0_2022.08.23.1622.LLX/MisData/MisAddition/vssver2.scc
Normal file
BIN
MisData_3.0_2022.08.23.1622.LLX/MisData/MisAddition/vssver2.scc
Normal file
Binary file not shown.
Reference in New Issue
Block a user